<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=299788&amp;fmt=gif">
Skip to content


If you use Power Scripts, then you know that SIL scripting can be used for many scenarios - Live Fields, SIL Listeners, and SIL Scheduler are just a few. In this blog post, I'm going to focus on the SIL Validator functionality that makes fields required when a specific field is a certain value.

Let's talk about this specific scenario in which the SIL Validator can assist. It is understandable to not want to overwhelm the user with a lot of fields on a transition screen if it's not necessary, so our goal is to stop the user from proceeding only if fields need to be required. If the user selects "Yes" for "customfield_5," then "customfield_1" through "customfield_4" are made required by presenting an error message on the Close transition. 

The SIL language is quite simple and straightforward with its naming conventions, such as "isNull" and "getIssueFields," and has many helpful functions that allow the scripts to remain clean and efficient. 

The "getIssueFields" function returns an array of all of the fields present for the specified issue key. This way you can validate whether "customfield_5" is "Yes" and show the appropriate error message. In the sample script below, we use "issueType" as a standard system variable you need to validate.

Lastly, we return the error message that constructs a string of all the fields that are null and shouldn't be if "customfield_5" is "Yes". For example, if "customfield_1" and "customfield_2" are empty, and "customfield_5" is "Yes," then the error message would be "Mandatory fields not filled. Fields: customfield_1, customfield_2."


// Description: SIL script to make specific fields required if field "customfield_5" is "Yes" on the Close transition
string[] fields = getIssueFields(key);
if (fields["customfield_5"] == "Yes" && (issueType == "issuetypeA" || issueType == "issuetypeB" || issueType == "issuetypeC" || issueType == "issuetypeD")) {
    string message;
    if (isNull(fields["customfield_1"]) ) message += "Customfield_1, ";
    if (isNull(fields["customfield_2"]) ) message += "Customfield_2, ";
    if (isNull(fields["customfield_3"]) ) message += "Customfield_3, ";
    if (isNull(fields["customfield_4"]) ) message += "Customfield_4, ";
    if (!isNull(message) ) {
        message = substring(message, 0, length(message)-2);
        return false, "Mandatory Fields not populated", "Mandatory fields not filled. Fields: "+ message;

This is the very edge of what Power Scripts can do. I encourage you to keep exploring and share your learnings with the world. There are many of us out here always looking for new ways to optimize our scripts. 


definitive guide to transitioning from itsm to esm

See More From These Topics