Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Built-in script - escalation service set to close and update customfields

Paul Eichholzer October 14, 2015

I need to automatically close issues in state open after 30 days. The transition is a no-brainer and works fine combined with the CRON expression. What does not work is the update of the two customfields. "RCP Request Resolution" is a "Select list, Single choice" field and "RCP Resolution Comment" a "Multi Line, Free text). Here is the code I wrote which does not create any error logs:

import com.atlassian.jira.component.ComponentAccessor
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("RCP Request Resolution") def cfConfig = cf.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {it.toString() == 'Dropped'} issue.setCustomFieldValue(cf, value)
def cf1 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'RCP Resolution Comment'}
issueInputParameters.addCustomFieldValue(cf1.id, "Dropped due to inactivity")

We are using JIRA 6.3.15 and Scriptrunner 3.0.16.

Thank you in advance for your assistance.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
JamieA
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 Leaders.
October 15, 2015

It's the same as this: https://answers.atlassian.com/questions/31657109 (not to mention https://jamieechlin.atlassian.net/browse/GRV-817)

First get the Option object corresponding to RCP Resolution Comment, then set that.

 

Paul Eichholzer October 15, 2015

Thank you for your response.

I copied the code from the first link provided. So the only difference I have found is in the line "def cfConfig...". I changed from "cf." to "selectCf." and got this error code:

No such property: selectCf for class: Script164

Code looks like this now:

import com.atlassian.jira.component.ComponentAccessor def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("RCP Request Resolution") def cfConfig = selectCf.getRelevantConfig(issue) def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {it.toString() == 'Dropped'}  issue.setCustomFieldValue(cf, value) def cf1 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'RCP Resolution Comment'}  issueInputParameters.addCustomFieldValue(cf1.id, "Dropped due to inactivity")

Sorry, I am new to Scriptrunner.... Trying to get better in it :-)

Paul Eichholzer October 19, 2015

This bit of code is not working under the escalation service in built-in scripts but with the post-function it does... So escalation-service is pushing the issue from open to closed and the post function is adding the values to the fields. import com.atlassian.jira.component.ComponentAccessor def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("RCP Request esolution") def cfConfig = cf.getRelevantConfig(issue) def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {it.toString() == 'Dropped'} issue.setCustomFieldValue(cf, value) def cf1 = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("RCP Resolution Comment") issue.setCustomFieldValue(cf1, "Dropped due to inactivity") Thanks again for your help.

TAGS
AUG Leaders

Atlassian Community Events