I'm trying to create a generic Create and Link operation. Using the Create constrained issue example, I'm fairly close.
I created a raw xml fragment, and removed the project id and issuetype id from the link.
I've added the Behaviour initializer for the Linked Issues field, and commented out the lines that set project/issuetype to read-only so the user can select.
When the create form is opened, all is well, Linked Issue is properly populated and read-only.
The problem is, if the user changes either project or issuetype, the Linked Issue field becomes editable and loses the values set by the initializer.
I'm assuming it's because the Create form is reloading, and I no longer have the correct contextid for the intializer. Is there a way around this?
The documentation states to use that script in an itializer function, which you're correctly doing. However, I think there is a known issue in our backlogs about values being reset after being set in an initializer. https://productsupport.adaptavist.com/browse/SRJIRA-2027
Have you tried associating that behaviour script with a field, instead of using it an initializer function? For example, take that script out of the initializer section and attach it as a server-side script to the Linked issues field. I may be totally wrong, but it's something worth trying perhaps.
You also might try adding some log.debug statements to check if your theory about the contextid changing is true.
@Mark Montminy, have you found a solution to your problem? We experience the same issue but only to some extent. We have a couple of web fragments (buttons) each for a different project but we want to keep Issue Type editable (with Project set to read-only). It works for most buttons/projects but one is faulty and after changing the issue type Create form is reloading and behaviour pre-populating the form isn't launched.
From the logs we can tell that contextId is null after changing the issue type.
What is more interesting other web fragments using the same behaviour (it is mapped to all projects) work well and after changing issue type in the create form, the contextId is properly retained.
I haven't had time to circle back and dig deeper into this, but no, still no solution.
As our usage ramps up, the desire to create linked issues will increase, so I'll need to get back to this, or pony up and pay for one of the addons that does this.
It just seems like it's something that can be done better with ScriptRunner.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs