Accessing the current screen
Looking for the documentation on the newest versions of Power Scripts for Jira 8 for Server/Data Center? Click here !
Availability
This feature is available starting with the following app versions:
- Power Scripts for Jira 2.5.3
- katl-commons 2.5.5
Starting with version 2.5.3 of Power Scripts for Jira, the screen argument was passed to the Live Fields scripts, so you can easily filter your actions based on which issue screen you are operating.
Syntax
argv["screen"]
Description
Returns the actual screen on which the current Live Fields SIL script is executed, this applies to both the initial script and any hooked script.
Return type
A string from the following list of predefined values, corresponding to the actual screen:
App Environment | Screen | Argument Value |
---|---|---|
Jira | View Issue | view |
Edit Issue | edit | |
Create Issue | create | |
Create Sub-Task | create-subtask | |
Transition Screen | trans_<transition_id> | |
JSD Customer Portal | Portal Landing | portal-landing |
Create Request | create |
Support for the Create Sub-Task screen is available starting with Power Scripts for Jira 2.5.5 and katl-commons 2.5.8 and above.
You can easily determine a particular transition's id, by checking your workflow administration page. They are listed as: Transition (id).
The following image shows Jira's transitions and their correspondent ids:
Example
This can be useful when you want to apply certain Live Fields actions only on editable screens for example, and not on view issue page.
For example, you want the assignee to always be set to user "x" when creating a new issue and with a Defect custom field having the "Development" value, without letting the user modify it.
At the same time, you want to set the current user as assignee by default whenever the ticket reaches the Resolve Issue transition screen but keep it editable.
You can achieve this by checking the screen argument and applying the live fields actions on the assignee field based on the argument value in the initial and in the hook script:
if(argv["screen"] == "trans_5") { //on Resolve Issue screen lfSet("assignee", currentUser()); } //set the hook script for the Defect custom field lfWatch("Defect", "Defect", "hook.sil");
if(argv["screen"] == "create") { //on Create Issue screen if(argv["Defect"] == "Development") { lfSet("assignee", "x"); lfDisable("assignee"); } else { lfEnable("assignee"); } } else { //other functionality based on Defect field value for other screens here.... }