Thanos,
Good day.
I need some help in constructing several simple scripted validators for the following scenarios:
Many thanks for your assistance!
Hi Jeff,
I have included some examples in the code block below which you can use to create some simple validators for your scenarios above.
// Summary Validator Code // Import Regex import java.util.regex.*; // Construct The Pattern to Match on Pattern pattern = Pattern.compile("([0-9]){10}"); // Check if the Summary Field is a match Matcher matcher = pattern.matcher(issue.summary); // Policy Number Validator Code import java.util.regex.*; // Construct The Pattern to Match on Pattern pattern = Pattern.compile("([0-9]){6}[-]([0-9]){2}"); // Check if the Summary Field is a match Matcher matcher = pattern.matcher(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Policy Number")).toString()); // Provider Validator Code import java.util.regex.*; // Construct The Pattern to Match on Pattern pattern = Pattern.compile("([A-Z]){1}([0-9]){9}"); // Check if the Summary Field is a match Matcher matcher = pattern.matcher(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Provider")).toString()); // Overpaid Amount code import java.util.regex.*; // Construct The Pattern to Match on Pattern pattern = Pattern.compile("([0-9]+)[.]([0-9]+)"); // Check if the Summary Field is a match Matcher matcher = pattern.matcher(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Overpaid Amount")).toString());
Also in the screenshots below I have shown how I have configured the first 2 validators. You may wish to tweak the regular expressions defined inside the pattern variable in order to further suit your requirements.
Summary.pngPolicyNumber.png
I hope this helps
Many Thanks
Kristian
Kristian,
Many thanks for the concreteness of your reply to me, a neophyte developer/coder.
I greatly appreciate your time and assistance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeff,
You can use regular expressions for you checks and because the conditions you mention are not anything 'extreme', there are a lot of online tools (for example http://regexr.com/) that can help you. Now once you have the regular expression you can easily make a comparison.
Now a few notes regarding on how to retrieve the info you need from the issue. issue.summary for the summary and cfValues['Policy Number'] for custom fields. For more information have a look at validators documentation, if you still need more assistance give me a shout (and add '@' in front in order to mention me).
Kind regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also see the validators recipes: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.