Versions Compared

Key

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

...

Addressing fields by its Jira internal name is not useful. Nobody likes to write 'customfield_12067' instead of a meaningful variable name. Thus we allow addressing allowed to address the fields by name though with the disadvantage that this may prove erroneous (certain errors may appear: field name resolution does not take into account that there may be more than one custom field with that name).

Look into the following code:

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

 

 

Without comments, this This code is meaningless , without comments as the whole script purpose evades from the sight of the programmer's eye. A better option is following:

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

 

As we mentioned, this style of coding Such coding style has the disadvantage that there may be more than one custom field named "with Reported User "name. in such case SIL takes into account the first custom field resolved by name . This may not prove exactly what you want and may lead to confusion, incorrect results and last but not least, frustration. We want to avoid frustration at any cost. Plus, we do not like very much the syntax #{custom field name containing spaces} - even if it was requested by our users -, since we consider it is cluttering the code.in such case. Therefore, SIL has created its own custom field naming system, one that is independent of the IDs attributed by Jira to custom fields and one which can provide the 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 'sil.aliases', which is placed in Kepler Home directory (usually 'kepler'). This file must contain pairs in the form alias=customfield_id. For our example above, we should edit it and put an entry like:

...

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

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

  

Now , the code looks clean , and the script function creator is clear , even without comments.

Summary

...

Using SIL aliases instead of custom fields ids IDs and names is supreme. There are important results when maintaining a complex Jira install:

  1. When and if a custom field gets deleted and recreated, its id will changeID changes. Using SIL aliases allows you to keep your code unchanged, you just need to point in the sil.aliases file the new custom field id ID for that alias.
  2. May simplify the syntax and may clarify the 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 production environment. You do not want to work directly into production (that would be a very bad thing to do, don't do this at home) so normally you develop your new workflow on the test machine environment and you add a new custom field, because the business needs it. 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 name (but . But Jira assigns its own idID, which may be different from the id from 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 idID, you need to go through every script and do a search and replace with the new idID. If you referred it by name, maybe your colleague just added a custom field, used in some other project, that has the same name.

...