Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cant find Script runner Logs(Fast Track Transition an Issue Script Condition)

Hemanshu Sood
Contributor
June 25, 2018

Hi,

I have written a script condition for fast  track transition an issue post function, according to which , if the value of a custom field changes , then the transition is done to another stage.

Have 2 queries:

1) Script is running successfully, (No Failure found in last 6 executions), but the transition could not occur.

2) Could not find the logs in catalina.out .

Please assist

PFB the script:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

boolean status = false

IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField myCustomField = customFieldManager.getCustomFieldObjectByName("field name 1")
String producttype = (String) issue.getCustomFieldValue(myCustomField)



IssueManager issueManager1 = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager1 = ComponentAccessor.getCustomFieldManager()
CustomField myCustomField1 = customFieldManager1.getCustomFieldObjectByName("field name 2")
String distribution = (String) issue.getCustomFieldValue(myCustomField)

if (producttype.equalsIgnoreCase("Approved") || producttype == null) 

{
status=true
}

if (distribution.equalsIgnoreCase("Approved") || distribution == null)
{
status=true
}
return status

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Joanna Choules
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
February 10, 2021

Hi Omar,

 

There is no need to use updateValue here. To set a custom field on the issue being transitioned, you only need to call setCustomFieldValue on the issue object that's passed in the script bindings:

issue.setCustomFieldValue(targetField, "U-RES")

You can see more examples in our documentation. Note that, for this to work, your post function must come before the Update change history for an issue and store the issue in the database function: this is the function that Jira uses to persist any new field values to the database. Also, the issue variable must still be pointing to the Issue object that was passed in the bindings. That means you'll need to get rid of the line where you redefine issue:

def issue = issueManager.getIssueObject(issue.getKey()) //<-- remove this

As far as I can tell from your code, there is no need for this redefinition anyway.

I hope the above helps - please let me know if you need any of it elaborating on.

 

Joanna Choules, Adaptavist Product Support

Omar Morales
February 10, 2021

Hello!

Thanks for the information! the Issue object redefinition makes sense, and I have made the changes you recommended. However after removing the line that redefines the issue I get a STC error message at this line.

def pullRequestData = devStatusSummaryService.getDetailData(issue.id, "stash", "pullrequest", currentUser).right().get().getDetail()

where it complains about not finding matching method getDetailData. I found this page  but I'm afraid I couldn't quite make out what the root cause of my STC error is.

Any advice?

Omar Morales
February 11, 2021

I figured it out.

my situation fell under the case

There are limitations to the type checker. It is possible to write code that shows errors, but it is valid and executes fine.

that the page I linked above talks about. My post function script is execute and works properly.

Thank you so much

TAGS
AUG Leaders

Atlassian Community Events