Versions Compared

Key

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

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 Jira Service Desk 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:

Image Removed

Use ‘For Field’ and display message against the field

This approach is best suited when you are validating a single field. For example,

.

Using the ‘For Field’ option in the validator

Consider you want to check during the request creation that the Component/s of the issue is “Database” only.

  1. In the Scripted Groovy Validator add the Groovy script. For example:

    Code Block
    issue.getAsString("components") == "Database"
  2. Input the Error message as The Components should be Database

  3. Select the Component/s field under “For field”

  4. Save the validator and publish the workflow

Now when you create the request from the portal the validation message “Please enter Component/s field” “The Components should be Database” is appended to the default message as shown below.

Use Image Added

Using a script that returns Map<String,String>

to display error message against fieldsThis approach is best suited when you want to display a different custom message for multiple conditions. For example,

Consider while requesting an account you want to validate that an the selected assignee is selected and belongs to a specific group . And you would want to and if not return custom error messages based on the selections. Use 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.

  1. In the Scripted Groovy Validator add the Groovy script.

    Code Block
    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"]
  2. Input the Error message as Assignee is mandatory. Note this is overridden by the custom messages above.

  3. 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.

Image Added

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@22cf51
showSpacefalse
sortmodified
typepage
reversetrue
labelskb-how-to-article jmwe-server
cqllabel in ( "kb-how-to-article" , "jmwe-server" ) and type = "page" and space = "JMWE"
Page Properties
hiddentrue

Related issues