Hi,
I am trying to set a single select field using a text string from another source. Here is the code I have thus far:
def cfFixDeploymentType = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Fix Deployment Type'}; CustomFieldType customFieldType = cfFixDeploymentType.getCustomFieldType(); newissue.setCustomFieldValue(cfFixDeploymentType, customFieldType.getSingularObjectFromString("Design")); issueMgr.createIssue(currentUserObj, newissue);
Not sure what I am missing here...
The customFieldType.getSingularObjectFromString is returning "null" if I log it.
customFieldType returns com.atlassian.jira.issue.customfields.impl.SelectCFType@253af1c3 if I log it.
There is a "Design" option associated with the select list.
Running on JIRA 4.4
Community moderators have prevented the ability to post new answers.
This will be related to http://confluence.atlassian.com/display/JIRA/Plugin+Developer+Notes+for+JIRA+4.4#PluginDeveloperNotesforJIRA44-Single-andMulti-SelectCustomFieldChanges
Design must be a valid option in the target custom field.
Add some code like this (this is just a pointer, I don't expect this to work ootb):
FieldConfig fieldConfig = cfTarget.getRelevantConfig(issue) Option o = optionsManager.getOptions(fieldConfig)?.find{it.toString() == "Design"} issue.setCustomFieldValue(cfTarget, o)
Hi Jamie,
Works like a charm... Thank you!
The only extra changes I had to make were to add the includes and to instantiate the OptionsManager.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I try to do the same but in my case, I want to get the customfield's value from an issue and put it in another issue (same type), in the same customfield.
Here my code :
CustomField customField = customFieldManager.getCustomFieldObject("customfield_10905") Object fromValue = currentIssue.getCustomFieldValue(customField); OptionsManager optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) FieldConfig fieldConfigTarget = customField.getRelevantConfig(childIssue)
Option newValueTarget = optionsManager.getOptions(fieldConfigTarget)?.find{it.toString() == fromValue} childIssue.setCustomFieldValue(customField, newValueTarget)
But it doesn't work. No exception, but no setted value in the "childissue". (this code is executed during post function in the "currentIssue")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'd ask a new question, I'm not sure this is related.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did like this.I got the option id from that i have set the option value as below
Option opt = optionManager.findByOptionId(Long.valueOf(logConvert));
<font style="font-size: x-small;" size="2"></font>
ArrayList myCompo =
<font style="font-size: x-small;" size="2"></font>new<font size="2"> ArrayList();</font>
myCompo.add(opt);
issueObject.setCustomFieldValue(customFieldcompo,myCompo);
Thankyou all!!
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.