Hello,
I want to create a condition in a Script Fragment : "Constrained create issue" with a customfield value of the current issue and it doesn't work :
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fist = customFieldManager.getCustomFieldObjectByName("FIST")
fist == "FIST avec attente"
Please, how can I do that
Best regards,
Pascal Malfoy
Hi Pascal,
getCustomFieldObjectByName simply fetches an object representing the custom field itself (i.e. the thing you see when you go to Administration > Issues > Custom fields). To get the value of a custom field for a specific object, you then need to use getCustomFieldValue:
issue.getCustomFieldValue(fist) == "FIST avec attente"
This replaces the final line of your current script: the rest of the code stays the same.
Yours,
Joanna Choules, Atlassian Product Support
Thanks a lot Joanna,
the syntax is well and accepted by the fragment verification but it seems not to work.
I forgot to precise the customfield is a Select list (Single choice) type and I think it is the problem.
What do you think and what it the new syntax ?
Thanks again for your response and your reactivity,
Pascal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pascal,
In that case you would want to use issue.getCustomFieldValue(fist).value. Note that the static type checker will flag this as a problem because it cannot be sure ahead of time that the result of getCustomFieldValue will have a value property, but there should be no problems when the code actually runs.
Joanna
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.