Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Show custom error message on service desk request creation
This article describes how to display a custom error message on the service desk request creation screen while using the Scripted (Groovy) Validator. This is because Jira Service Desk does not display validator messages properly (https://jira.atlassian.com/browse/JSDSERVER-5822) in the portal view. There are two approaches to handle this. In both the approaches, the configured error message is appended to the default error message of Jira as shown below.
Using the ‘For Field’ option in the validator
Consider during the request creation you want to validate that the Component/s of the issue is “Database”
In the Scripted Groovy Validator add this Groovy script.
issue.getAsString("components") == "Database"
Input the Error message as The Components should be Database
Select the Component/s field under “For field”
Save the validator and publish the workflow
Now when you create the request from the portal the validation message “The Components should be Database” is appended to the default message as shown below.
Using a script that returns Map<String,String>
Consider while requesting an account you want to; validate that the selected assignee belongs to a specific group and return custom error messages based on the selections. You need to write a Groovy script that returns a Map<String,String>
where each key is a field name or ID and the corresponding value is the error message to display for that field.
In the Scripted Groovy Validator add the Groovy script.
if(!issue.get("assignee")) return ["assignee":"Assignee field is mandatory"] if (issue.getAsString("System") == "Billing Services" && !issue.assignee.isInGroup("billing")) return ["assignee":"Assignee should belong to Billing Services group"] if (issue.getAsString("System") == "Financial Services" && !issue.assignee.isInGroup("finance")) return ["assignee":"Assignee should belong to Financial Services group"]
Input the Error message as Assignee is mandatory. Note this is overridden by the custom messages above.
Save the validator and publish the workflow
Now when you create the request from the portal the validation message is appended to the default message.