Versions Compared

Key

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

...

Excerpt

Aliases represents a powerful tool to refer custom fields indirectly making your scripts function obvious.


The

...

case for the aliases

Addressing fields by its their Jira internal name is not useful. Nobody likes to write 'customfield_12067' instead of a meaningful variable name. Thus, we allowed to address the fields by name though with the disadvantage . Though you should keep in mind that certain errors may might still appear : because the field name resolution does not take into account that there may can be more than one custom field with that name.

...

This code is meaningless without comments as the whole script purpose evades from the programmer's eye. A better option is would be the following one:

Code Block
if(isNotNull(#{Reported User}) // or customfield_10001 if accessed by number
{
  assignee=#{Reported User}; // assign the report to him or her
}

...

Such coding style has the disadvantage that there may might be more than one custom field with Reported User name. In such case cases SIL™ takes into account the first custom field resolved by name. Therefore, SIL SIL™ has created its own custom field naming system, one that is independent of the IDs attributed by Jira to custom fields and one that can provide the a much better distinction of the custom fields names. The feature is called SIL™ aliases, and allows you to alias any custom field with a friendly name. Let's see how this simple example looks with aliases.

...

Creating aliases is a simple task of editing a properties file named the 'sil.aliases', that is placed in  properties file in the cPrime Home directory. This file must contain pairs in the following form: alias=customfield_id. For our example above, we should edit it and put an entry like this:

Code Block
titlesil.aliases
# custom fields aliases
reportedUser=customfield_10001


The script may be re-written You can rewrite the script in another way , and use alias instead of the custom field ID or name the alias is used:

Code Block
if(isNotNull(reportedUser)) {
  assignee=reportedUser;
}

...

  1. When and if a custom field gets deleted and recreated, its ID changes. Using SIL SIL™ aliases allows you to keep your code unchanged, you just need to point in the sil.aliases file the new custom field ID for that alias.
  2. May simplify the Simpler syntax and may clarify the clearer meaning of the scripts.
  3. Aliases provide independence of the Jira instance.

Since 1 and 2 are obvious, let's discuss the 3rd point: the independence of the Jira instance.   Think of two Jira systems, for instance test environment and a production environmentone. You do not want to work directly into production so normally you develop your new workflow on the test environment and you add a new custom field. Now, everything is ready and you want to publish changes into production system, so:

  • You create on the production system a custom field with the same namename on the production system. But Jira assigns its own ID, that may be different from the ID on the test system.
  • You move over the SIL™ scripts.
  • You import the workflow, with the paths changed to the above SIL™ scripts if necessary.

...

Now, if you referred your custom field by its ID, you need to go through every script and do a search and replace the old ID with the new IDone. If you referred it by name, maybe your colleague just added a custom field, used in some other project, that has the same name.

...

Note

It is important to keep aliases names unique. If more than one alias with the same name exists, the last one is taken into account, the rest are discarded.


Another

...

example

If you're still not convinced, let's take a look at another example. Look into this post function:

...