Custom fields support SIL script
A useful tool for getting the most support for Jira Product Discovery.
This script is designed to discover the custom field ID’s of the Product Discovery fields that are seeming hidden in the product. The script will attempt to create SIL aliases for these fields so that they may be used normally in the future scripts.
What it does
Part A: Finding the custom fields
Step 1: Dynamically search
This step will find all the Product Discovery projects and get the all the ideas from each project. Then it loops through every idea and gets the custom fields used in that submission. The idea being that the field needs to be populated to get the information returned, by searching every issue it has a high probability of finding all the fields.
The nice part about this step is that if Atlassian adds any new fields they will automatically be picked up automatically without modifying the script.
Step 2: Static/heuristic search
In the event that custom fields are not populated this step uses a predefined list of supported custom fields to search for the field ID.
Notice the progress and output from the script is displayed in the console tab at the bottom of the SIL Manager (image above). The output from each step is marked.
Part B: Creating the SIL aliases
Now that the script has retrieved all the IDs for the custom fields, the next step is to create the SIL aliases. The alias name is dynamically generated using camel case. So, for example, if the custom field name is “Idea short description” the camel case alias would be ideaShortDescription.
In the event that an alias can not be created, an error message is displayed in the output with a link to the documentation about how to create the alias manually. The exact code that should be used to create the alias manually is also displayed in the output. However, the main reason that such an error occurs is that the alias already exists so the first step should be to verify if the alias is already in the sil.aliases file.
What to watch out for
The script adds the new aliases directly to the sil.asliases file. On some rare occasions a line break may be missing from the end of the last line which will cause new lines to bump up against the last existing line (see the image below). This usually only occurs when someone manually deletes the line break. Since the aliases are combined they are not formed correctly and will not work as indented. It is a good idea to check this file after running the script.
There are some other things to watch out for that are described in the known limitations page. It is important to review this material as well.
Code
To run this code:
Create a new file in the SIL Manager (right click on a folder)
Copy and paste the code below into the new file
Click the green run button at the top of the SIL Manager
Watch it go!
This script was written in such a way that it will work on anyone's Jira Cloud instance and with any Product Discovery fields that it can find. Because of this the code is much longer than it really needs to be, the SIL language is much easier then the code below may make it appear.