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
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.