Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

Looking for the documentation on the newest versions of Power Scripts for Jira 8 for Server/Data Center? Click here !

Contents

Table of Contents
maxLevel3
excludeSee also

One of the best features in Power Scripts is customizing workflows. Using the power of SIL, you can add conditions, validators, and post - functions on any transition from your workflow.

Writing

...

validators, post functions, and conditions

After you install Power Scripts for JIRAJira, go to the Administration > Workflows page and create a workflow, associated with a project.

...

Clicking a transition will show the transition triggers, conditions, validators, and postfunctionspost functions.


Keep in mind that:1. Whenever an issue

  1. The post functions are called every time when a ticket advances from one state to another

...

  1. .

...

  1. The transition is made possible only if the conditions are fulfilled. Therefore, a condition must return "true" or "false" to signal whether the condition is met or not.

...

  1. The validators must validate

...

  1. data before the transition is fired. Subsequently, a validator is entitled to return "true" or "false" and optionally the field and the error message you want to show in the interface.

An important consequence of the above model is that conditions and validators should not have side-effects. In fact, Power Scripts for JIRA Jira is discarding modifications of the issues, allowing them to occur in the postfunction post function only , but it cannot discard modifications made on another database, for instance, applied using the sql routine (see sql() routine for details).

To create conditions, validators and postfunctionspost functions, click the corresponding Add link at the top of the workflow management tab.

Note
titleNote

For the cloud version for conditions and validators see Cloud Conditions and Validators

The following image shows the creation of a test post function.

...

After you click the Add button, you can write or reuse your SIL (in this case, a SIL postfunctionpost function) by going through the wizard steps below.

...

Click Next and write the code. In this case, we added a comment to certain linked issues:.


The next step is just for confirmation.

...

Tip

You can create a new script or pick a script that was already created ( or even used for other purposes ) in the silprograms folder (or wherever those files are located, established by your configuration).

By providing a meaningful name to your program and by clicking the Finish button, you are now ready to extend your Jira workflow:.


Returning into Return to the transition screen, you will see that your newly added post - function will be is reflected in the view:


Warning
titleModifying Issues

You should avoid Avoid modifying issues in conditions and validators, as they are supposed to be read-only. Do not yield to that temptation! You should modify issue values (or create new issues, or change anything) in the postfunction post function only. In fact, SIL runs executes the validators and conditions in the read-only mode, discarding changes.

Info
titleInfo

Starting with Power Scripts for JIRA Jira 4.0, your SIL program will be saved either on the disk in the folder specified in the configuration or in the database. The filename is obtained by removing any invalid characters from the program name you entered and appending a number to help you browse through different versions of the same file.

Note
titleNote

For the best experience, we recommend Google Chrome or Mozilla Firefox.

Return codes

Returns codes are different for validators, conditions and postfunctionspost functions.

For

...

validators

Code Block
return false, "assignee", "We have failed, assignee is not ok";

...

For example, you can check whether certain fields were filled out during a workflow transition. To do that, use the hasInput routine.

For

...

conditions

Code Block
return false; //to signal that condition is not fullfilled.

Just tell Jira this condition is not fullfiled.

For

...

post functions

Code Block
return;

return ends the program, any values are ignored.

Note
titleNote

When writing postfunctionspost functions, conditions or validators for the Create issue transition, ensure that the SIL program is the last step of the transition. This is necessary because we need Jira to create the actual issue and save it to the database using the input parameters before we can access it.

Note
titleNote

In general, it's a good idea to place your postfunctions post functions after all standard postfunctionspost functions.



Workflow

...

view

This view will help you browse through your workflow without having to open the program every time to see what it does.

...

Finally, you have the error notifier which tells you whether the program is correct. If there are any errors, open the program for a more detailed description of the cause. If the program is correct, this line will be blank.

See also

...