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

How to apply Create Constrained Issue to the "current" project - Scriptrunner

I would like to use the functionality that is described in the Adaptivist documentation for how to create a constrained issue. I would like to have this apply to all projects in the system, but the project selection to be the "current project" where the menu item is selected from.

It appears that I can only select a specific project which would mean this would have to be set up potentially for every project?  

If this is not the right way, then can anyone advise an alternative?

Our Use Case is that we would like users to have the ability to create a new issue (defect) from an enhancement (that caused the defect) and link them together.  We would like this functionality for all projects where Enhancements are part of the scheme. 

We have alternative use cases of creating a Request for Change from a Problem issue type - but the functionality is the same.

Thank you in advance!

1 answer

So, the Project drop-down is required for the Create Constrained Issue dialog fragment, and it specifies the destination project.

For your use case, it sounds like you'll want the defect issue to always be in the same project as the enhancement. If that's correct, then I think you could set this up with a plain custom web item. You'll notice that the fields are pretty similar, since the Constrained Issue fragment extends the custom web item behind the scenes.

The main trick is that for the action, you'll choose Navigate to a Link. For the link, you'll enter a relative URL like this:


Just replace the issuetype parameter (10001) with the ID of your Defect issue type. You can get that ID from the edit link for that particular type in the Issue Types admin page.

For your condition, you'll want something like == "Enhancement"

so that the button only shows up on Enhancement requests.

You'll still setup the behaviour as described in the Create Constrained Issue documentation.

Hi Jonny,

With your suggested approach, is it possible to use Behavior plugin to set preset values in the form. Doesn't seem to work like the way it does for Dialogs. Specifically, there is no access to BehaviorContextId and contextIssueId.

Thanks in advance,

Ramandeep Sandhu

That's right, Ramandeep. Those variables are only set in the create constrained issue context. That said, there is an issueContext variable in the binding that will get you the same information (project & issue type). Whenever you're in the edit view, there's also an underlyingIssue variable to represent the issue in the database; notably, underlyingIssue is null on the create issue screen, since there is no saved issue yet.

Thanks for the reply Jonny. 

So how do I restrict the behavior to run only if the user clicked a custom webitem that I have added ?

We don't currently have a good means for doing stuff like that outside of Create Constrained Issue. We do have an issue in the backlog for it:


So as a workaround, is it possible to change the Project value using a behavior, when the Create Constrained Issue dialog opens ?

Full disclosure: Interacting with the project field or issue type field with a Behaviour is a bit dodgy. The reason is that as soon as you change projects, the behaviours context changes. Recall that all behaviours are mapped using Project and issue Type (or service desk and request type on the Service Desk side). 

There are a fair number of open issues related to this, and being noteworthy among them.

While I think you technically can set the value of a project field in certain contexts using a behaviour, you're likely to create headaches for yourself, as the behaviour context is immediately going to change when you do. In the Create Constrained Issue context, whatever project you set in that Script Fragment's configuration is going to be what you should expect. You might be able to use conditions to manage multiple, non-intersecting Create Constrained Issue fragments, but I'm not even sure exactly what you're trying to accomplish.

Less is often more with Behaviours. As someone who's been there fairly often, I'd recommend you take a step back and think about what you're really after before you build a house of cards. ;)

Thanks for the detailed explanation Jonny. 

Well, what I was trying to do was to add a shortcut to Create Linked Documentation type Issue for an issue. While using the Create Constrained Issue Fragment, I found that it needs a Project to be specified. Since we have multiple Projects, I was trying to avoid creating these fragments for each and every project - that is certainly hard to maintain.

So I was just trying to figure out If I could implement it in a generic manner for all the projects. Seems like there isn't a way to do that currently unless gets fixed.

Thanks for your reply.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Off-topic

Friday Fun: Virtual dance party!

Do dance parties help you relieve stress? How about *virtual dance parties*? My team holds virtual dance parties to brighten the mood of a tough day or celebrate an upcoming weekend.  Want t...

182 views 22 9
Join discussion

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