You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I want to create select List custom field using script runner and field will be having data from database but as I am new in this I am just creating select list custom field first. But I am facing following error . Am I following correct way to create custom field using script runner?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.context.JiraContextNode
import com.atlassian.jira.issue.context.GlobalIssueContext
import com.atlassian.jira.issue.issuetype.IssueType;
createCF()
CustomField createCF()
{
def cfManager=ComponentAccessor.getCustomFieldManager();
def selectList=cfManager.getCustomFieldType("com.atlassian.jira.issue.customfields.impl.SelectCFType");
def selectListSearcher=cfManager.getCustomFieldSearcher("com.atlassian.jira.issue.customfields.impl.SelectCFType");
List <JiraContextNode> context= new ArrayList<JiraContextNode>();
context.add(GlobalIssueContext.getInstance());
def bugIssueType = ComponentAccessor.getConstantsManager().allIssueTypeObjects.find {it.name == "Bug"}
List<IssueType> issueTypes = new ArrayList<IssueType>()
issueTypes.add(bugIssueType)
return cfManager.createCustomField("SelectList CF","Demo purpose",
selectList,selectListSearcher, context, issueTypes )
}
error:
2018-01-08 14:00:46,898 ERROR [runner.ScriptFieldPreviewRunner]: ************************************************************************************* 2018-01-08 14:00:46,899 ERROR [runner.ScriptFieldPreviewRunner]: Script field preview failed for field that has not yet been created java.lang.IllegalArgumentException: Invalid module key specified: at com.atlassian.plugin.ModuleCompleteKey.<init>(ModuleCompleteKey.java:49) at com.atlassian.plugin.ModuleCompleteKey.<init>(ModuleCompleteKey.java:29) at com.atlassian.plugin.manager.ProductPluginAccessorBase.getEnabledPluginModule(ProductPluginAccessorBase.java:180) at com.atlassian.plugin.manager.ForwardingPluginAccessor.getEnabledPluginModule(ForwardingPluginAccessor.java:54) at com.atlassian.plugin.manager.EnabledModuleCachingPluginAccessor.getEnabledPluginModule(EnabledModuleCachingPluginAccessor.java:39) at com.atlassian.plugin.manager.ForwardingPluginAccessor.getEnabledPluginModule(ForwardingPluginAccessor.java:54) at com.atlassian.plugin.manager.ProductPluginAccessor.getEnabledPluginModule(ProductPluginAccessor.java:19) at com.atlassian.extension.plugins.ExtensionAccessingPluginAccessor.getEnabledPluginModule(ExtensionAccessingPluginAccessor.java:169) at com.atlassian.jira.plugin.customfield.CustomFieldTypeModuleDescriptorsImpl.getCustomFieldType(CustomFieldTypeModuleDescriptorsImpl.java:51) at com.atlassian.jira.issue.managers.CachingCustomFieldManager.getCustomFieldType(CachingCustomFieldManager.java:204) at com.atlassian.jira.issue.CustomFieldManager$getCustomFieldType.call(Unknown Source) at Script161.createCF(Script161.groovy:11) at Script161.run(Script161.groovy:7)
Hi Vedant,
Where are you running this script? By the look of the error message it seems you're using the preview functionality of the Script Fields form, but this is not the sort of code that you would want to put in a script field, since it will be run (thus creating a custom field) every time the script field is viewed (which will probably be a lot of times). It would help us to assist you if you could describe the intended purpose of the script.
Even without knowing what the script is for, one problem I can see with it is that you are using the wrong string for the custom field type key. Instead of "com.atlassian.jira.issue.customfields.impl.SelectCFType", you should use "com.atlassian.jira.plugin.system.customfieldtypes:select". You can find information on how to construct the keys for various field types in the documentation for CustomFieldManager.
Thanks,
J
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.