Post function that sets a value of an InTENSO [Dynamic Forms] - Dynamic Select field

Duane Cronkite July 12, 2018

Looking for custom code for a post function that sets a value of an InTENSO [Dynamic Forms] - Dynamic Select field on transition with scriptrunner.

Couldn't find anything yet. The code below didn't seem to work from scriptrunner's website.

import com.atlassian.jira.component.ComponentAccessordef cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Favourite Fruit")def cfConfig = selectCf.getRelevantConfig(issue)def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {    it.toString() == 'Lemons'}issue.setCustomFieldValue(cfSelect, value)

 

2 answers

1 accepted

0 votes
Answer accepted
Duane Cronkite July 13, 2018

For anyone who needs this in the future...this worked:

import com.atlassian.jira.component.ComponentAccessordef cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Favourite Fruit")def cfConfig = cfSelect.getRelevantConfig(issue)def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find {    it.toString() == 'Lemons'}issue.setCustomFieldValue(cfSelect, value)
0 votes
Sana Safai
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.
July 13, 2018

I would recommend that you use the Script Console to see what data you get from your various statements. For instance, try returning value:

def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find { it.toString() == 'Lemons'}

//add below statement right after the above statement

return value

What do you get?

You will have to define issue first though

def issue = ComponentAccessor.getIssueManager().getIssueObject("ISSUEKEY HERE")

Duane Cronkite July 13, 2018

received this error:

groovy.lang.MissingPropertyException: No such property: ComponentAccessor for class: Script88 at Script88.run(Script88.groovy:1)

Sana Safai
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.
July 13, 2018

You need the rest of your script too.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events