Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

error while creating custom field using script runner

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)

1 answer

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you