Hi,
I'm using the Scripted Fields in ScriptRunner to display the last comment of the issue.
Even though the script runs successfully, it displays it as empty in the filter, has anyone encountered this?
Hey @Oleksii Zhelaha ,
For for Scripted Fields (SF) on Cloud, it works as an "On Load" update at this point of time. You need to open the issue and let it update - then you should be able to see the last comment field get populated.
For whatever reason you need to regularly update the SF with data because tickets are not viewed - it is technically possible to run a Scheduled Job to update the SF fields with the required data but there are limitations (there could be more as well depending on what you want to do exactly....)
If you are interested in doing that, then you probably can use a sample like:
//your query
def jqlQuery = 'assignee = currentUser() AND resolution = Unresolved order by updated DESC'
// Fetch issues based on the JQL query
def searchResult = get("/rest/api/3/search")
.queryString("jql", jqlQuery)
.queryString("maxResults", 50) // Adjust the maxResults to your needs
.queryString("fields", "comment") //fetch the comment field or whatever
.asObject(Map).body
//whatever you wanna do for your searchResults goes after this for checking, updating etc etc
//just a random sample , I didn't close it..
searchResult.issues.each { issue ->
def issueKey = issue.key
// Fetch issue data including changelog blah blah blah
def response = get("/rest/api/3/issue/${issueKey}?expand=changelog")....
Feel free to Get Help from us at Adaptavist/ScriptRunner, or if you want to get a feature demo etc - feel free to book time with us ScriptRunner CSM .
Hope it helps,
Sean
well, I added a new comment to the issue, but it does not appear. what is the point of creating a built-in scripted field if you need to use an additional script to use it? not sure if the problem is this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not see anything about additional scripts in this doc:
https://docs.adaptavist.com/sr4jc/latest/features/scripted-fields/example-scripted-fields
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use Scripted Fields like Jira Custom Field was just updated early March 2024. At the moment, it is a known limitation that the scripted field recalculates only upon issue load. We are working to improve this however there is currently no time frame as to when this will be released.
The sample i've shared is IF you would like to use a Scheduled Job to regularly update the field without going into the ticket individually which is a potential workaround so that you can see the details in the places you want like the filters, or dashboard:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, thanks man, I got it.
basically, I need to add a comment and then reload the page.
but looks like I found the issue in my case. I didn’t add this field to the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Sean Chua _Adaptavist_ , could you advise how to use Scheduled Job for this instant update? ;)
Run one of the scripts above every hour or something? I have a very large amount of filters on my dashboard where I need to see the last comment immediately. We are working as a support team and checking the comments from our customers is important for us.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Oleksii Zhelaha , apologies for the late response. I was off for a few days and caught up with stuff etc.
I don't have a sample for updating the comment itself but you can likely have a logic to;
For the query, you can use something like what I shared above, if there are many tickets which needs to be updated - you could hit some limitations there. So I would recommend you to open a Support Ticket with our ScriptRunner support engineers to see if they can investigate with you to meet your needs within their Support SLA .
Regards,
Sean
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What happens if you take that filter, add it to a gadget on a dashboard, and then display that field on your gadget?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.