Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner Behaviour: Set Default Project and Issue Type on Create Issue Screen

Krishnanand Nayak
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.
January 2, 2019

Need some help with setting up behavior to default the Project and Issue Type values on the Create Issue screen.

Condition : On the Xray Execute Test Screen, when the user clicks the Create Defect a Create Issue Dialog Screen is shown. 

Expectation:

  1. The Project and Issue Type should be defaulted to a preset value
  2. This behavior should not be triggered when the Create Button on the main menu is clicked.ExecuteTest.png

1 answer

1 accepted

1 vote
Answer accepted
Matthew Clark
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.
January 7, 2019

Hi Krishnanand

 

The execution page where you click the "create defect" button is an XRAY specific page which you can see from the URL
e.g.
http://localhost:8080/jira/secure/XrayExecuteTest!default.jspa?testExecIssueKey=XRAYT-2&testIssueKey=XRAYT-3

Scriptrunner does not load behaviours on the "XrayExecuteTest" page where you click the "Create Defect" button.


The browsers developer console log will show a message saying that
[SR Behaviours] Behaviours not applicable to the current form/screen

However, when you click the "Create Defect" button it opens a create defect (create issue) form which does load the behaviours.

You may be able to use the API methods described here to control the form based on the link that was used to open the create defect (create issue) form:

getBehaviourContextId()
Gets the ID of the web item that was clicked

getContextIssueId()
Gets the ID of the issue that was on the screen when the item was clicked.

However, currently there is a bug with those 2 methods which you can watch here to be notified when it is fixed

When this bug is fixed I suggest trying the methods above to get the link name and use that to control the Project and Issue Type available to the create defect (create issue) form.

 

Alternatively, you could use custom Javascript to modify the Link HTML tag of the button and append the ProjectId and IssueTypeId to the url:

e.g. change:

http://localhost:8080/secure/CreateIssue!default.jspa?issuetype=&decorator=none

to

http://localhost:8080/secure/CreateIssue!default.jspa?pid=10000&issuetype=10004&decorator=none

pid is the Numerical ID of your project

issueType is Numerical ID of your Issue Type

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events