Can anyone provide a code snippet how to prepopulate the compontent field on create issue.
Adding templates to description fields works fine but a slightly adapted code for components does not work.
def comp = getFieldById("component")
def componentValue = "myComponent"
if (!comp.formValue) {
comp.setFormValue(componentValue)
}
Hi Peter,
This is Olly from Adaptavist's ScriptRunner Support!
The reason this isn't working, is because you are using underlyingIssue on Create, which doesn't work due to underlyingIssue being null on Issue Creation.
To achieve your requirement, you simply need to:
1. Ensure that the Component you want to add to the Issue with the Behaviour already exists.
2. Add the following code to the Initialiser:
//check if the Issue operation is Create
if(actionName.equals("Create") ){
//retrieve the Component field, and populate with an existing Component
getFieldByName("Component/s").setFormValue("Example Component")
}
Hope this answers your question!
Thanks,
Olly
Hi Olly
saw your comment too late and got it working myself. Nevertheless your background information is useful for the future.
Thanks a lot,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The id for Component/s is "components"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.