Versions Compared

Key

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

...

Code Block
titleSIL Code
string errorMsg = "Invalid social number format.";
string REGEXP = "^\\d{3}-\\d{2}-\\d{4}$"; 
if(!matches(customfield_10100, REGEXP)) {
   return false, "customfield_10100", errorMsg;
}

Force a custom field to be required if

...

another field was set to a certain value

A SIL validator which makes custom field Product with id customfield_10200 required in the resolve screen only if the resolution was set to Fixed:

Code Block
titleSIL Code
string errorMsg = "To resolve the issue as 'Fixed' you should give a value to field 'Product'.";
if(resolution == "Fixed" && !hasInput("customfield_10200")) {
   return false, "customfield_10200", errorMsg;
}

In a similar way, you can make any custom field required based on another custom field value:

Code Block
titleSIL Code
string errorMsg = "The Address field is required.";
if(customfield_10100 == "Yes" && !hasInput("customfield_10200")) {
   return false, "customfield_10200", errorMsg;
}

In the above example we assume that the field with id customfield_10100 is a select list with options Yes and No, and when Yes option is selected, field Address with id customfield_10200 should be required.

Ensure that the issue hast at least one attachment

...