How to pre-fill the field "Linked Issues" of the "Create Issue" screen?

At the address https://confluence.atlassian.com/jirakb/creating-issues-via-direct-html-links-159474.html is explained how to build an HTML link that pre-fills the "Create Issue" screen.

I do not find any Key for pre-filling the "Linked Issues" field.

Is there any way to achieve this?

Also, which the source code file where all of the usable "key" are listed for CreateIssueDetails!init.jspa?

Thanks

1 answer

0 vote

You can do this with a Behaviour:

getFieldById("issuelinks-linktype").setFormValue("causes")
getFieldById("issuelinks-issues").setFormValue("ABC-1")

See https://scriptrunner.adaptavist.com/latest/jira/fragments/CreateConstrainedIssue.html#_behaviours_integration

Hi Jamie,

How can I "parameterise" the issue key I want to link to?

Basically, I have a "Custom Web Item" and I want that when this "Custom Web Item" is pressed the "Create Issue" screen pops up with the "Linked Issue" field already filled with the issueKey corresponding the issue that was shown when the "Custom Web Item" button was pressed.

Found the answer in your comment to one of my other questions. Thanks.

 

I link the other question here since it might be useful for other people as well: How to get a workflow postfunction to show the "Create Issue" screen with pre-filled values?

Hi Jamie, I was trying to implement your solutions and I have come across an issue.

Basically I would like to add a WebItem to create a new issue linked to the one currently displayed and belonging to the same project to which the one currently displayed belongs.

The issue with your solution is that I have to create a different CreateConstrainedIssue per project, because I am obliged to fill the field "Project" when creating the "CostrainedIssue".

Is there a way to generalise the approach so that can be applied to any project?

preview the "create constrained issue" with any project

Copy the xml, now edit in a text editor

In the url, replace the project id with ${issue.projectObject.id} or .key or whatever.

Then copy that xml into "custom xml module" or whatever it's called.

This works because the URL is processed by velocity.

 

Thanks Jamie. That worked.

However, now I am facing a more challenging issue. I would like the to have issuetype  parameter to be determined as detailed by the following REST end point.

CreateReq(httpMethod: "GET") { MultivaluedMap queryParams ->

    def issueId = queryParams.getFirst("issueId") as Long
    def issue = issueManager.getIssueObject(issueId)
    def CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
    def CustomField requirementsType = customFieldManager.getCustomFieldObject(11300)

    String RequirementsTypeName =  issue.getCustomFieldValue(requirementsType)
    String issueTypeId = ComponentAccessor.getConstantsManager().getAllIssueTypeObjects().find { it.name == RequirementsTypeName}.id


    Response.temporaryRedirect(
            URI.create(("${applicationProperties.baseUrl}/jira/secure/CreateIssue.jspa?pid=${issue.projectId}&issuetype=${issueTypeId}"))
    ).build()
}

I do not think that this can be processed by Velocity.

I tried to change the address of the XML fragment to point to the REST end point listed above, but with this modification the Create Screen does not get filled properly

You just want to redirect to a screen where the project and issue type is prefilled I think. It's a very different question, think it warrants a new question. It's not really SR related.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

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

136 views 0 4
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you