Good morning Atlassian Community,
Here's my problem :
I want to retrieve several different values contained in the same Jira Issue, then put everything together in a textfield customfield (<255 characters).
For that, here is the code I use :
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.Group
MutableIssue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Products'}
def cfValue = issue.getCustomFieldValue(cf)
def cf2 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Project Type'}
def cfValue2 = issue.getCustomFieldValue(cf2)
def cf3 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Branche Git'}
cf3 = "[" + issue.issueTypeObject.name + "]" + cfValue2 + "-" + cfValue +"-[" + issue.key + "]-["+ issue.dueDate +"]-["+ issue.reporter + "]"
Normally, this code is ok because it works in the Script Runner :

But, when executing it in the workflow, nothing happened (not even an error message in the logs). But, I've tested to put it instead of the summary and / or the issue description and it works :

Can you give me a clue about what I did wrong?
Another thing, when regarding the previous screenshot, I notice that the issue.key is null, which is normal because the script is executed like this :

I'm sure I'm missing, but can't figure out what exactly.
Thanks for your attention.
Cheers.
Fabien.
I see no code where you are setting a custom field value... something like issue.setCustomFieldValue(cf, "new value").
Your last line doesn't actually modify the issue.
You might be better off with a scripted field, as the code will be easier, and it will stay up to date if any of the inputs change.
No worries, hope you get it working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Huge shame on me!
I've already tested the issue.setCustomFieldValue at the time, but it didn't work (no doubt I've made a mistake).
Thanks again for your speed and accurate answer, I've been searching and searching for a time but in the end, I was blind about the code I wrote.
Cheers.
Fabien.
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.