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

Roberto Saltini September 18, 2016

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 votes
JamieA
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.
September 19, 2016

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

Roberto Saltini September 19, 2016

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.

Roberto Saltini September 19, 2016

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

 

Roberto Saltini September 19, 2016

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?

Roberto Saltini September 21, 2016

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?

JamieA
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.
September 22, 2016

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.

 

Roberto Saltini September 23, 2016

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

JamieA
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.
September 25, 2016

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
TAGS
AUG Leaders

Atlassian Community Events