Using the Create constrained issue example, but want project and issuetype selectable

Mark Montminy August 17, 2017

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?

2 answers

0 votes
Bartek Zukowski October 2, 2017

@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.

Mark Montminy October 31, 2017

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.

0 votes
Joshua Yamdogo @ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2017

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events