Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

handle message "customfield_XXXXX: This field is required."

Olivier MAZEN
Contributor
July 30, 2018

Hello there,

 

I have a requirement from my customer:

It is possible to catch the generic message "customfield_10438: This field is required." and display a specific one ?

 

I have made some research on Validator function but dont get how i can do it.

 

If you have any tips ?

1 answer

0 votes
Moses Thomas
Community Champion
July 30, 2018

@Olivier MAZENPlease see article on how to  add validator

https://confluence.atlassian.com/adminjiraserver/advanced-workflow-configuration-938847443.html

Better   have the Jira admin rights  then modify  workflow  by  adding validator on  any transition   you   wish  to.  in this  case on  a transition  use the field required choice  when  you  click  add validator.

 

Best!

Olivier MAZEN
Contributor
July 30, 2018

Hello Thomas

Unfortunatly the link seems to be ko, i get a 404 after click on it.

Olivier

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2018

This forum has a nasty habit of adding duff characters to the end of urls when you use the link function.  Try removing the .%A onwards stuff from it.

Olivier MAZEN
Contributor
July 30, 2018

Hello Nic,

 

my bad i just have to copy past the link : it works well :)

Anyway i didn'"t found my needs in the post.

I want to catch when JIRA performed the required field  verification catch the message and change by another one.

 

The controle on required field is done on the create issue but modify issue too.

 

Olivier

Moses Thomas
Community Champion
July 30, 2018

@Olivier MAZEN

My bad, didn't know how the  (.) came up, but i  have corrected it , in the documentation there is how to  add a  validator. As  i see you  want to  manipulate the   display  message, then you  will  need script runner plugin  installed,  then go to  workflow   and then click  on the transition  you want to  add the validator(don't forget to  add screen on this transition)by double clicking  the transition and then add your screen. To  add a  validator, single click  the transition , add validator > script validator > >  simple script  validator. You will   see examples by clicking show example afterchoosing simple script validator

Now just  need to  add a condition(groovy) depending on your needs

See other examples here: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html

You have possibility to  choose  field that should be mandatory when  condition is met  and enter any  message you  want.

Note  my  first comment will  not give you possibility  to  manipulate comment.

This  should  solve your need.

best!

Olivier MAZEN
Contributor
July 31, 2018

Hello,

thank for your answer.

I have the add on scritprunner. I get your point but there is no way to catch the standard controle?

Basically i just want to change a standard message by another one, if it is hardcode in a class or something i understand i can't do it. But there is a chance this is confiug threw a configuration file?

Moses Thomas
Community Champion
July 31, 2018

@Olivier MAZENAs i have mention you  can when  you  follow my explanation you  will  see that you  can  do  it  just i have mention.

Olivier MAZEN
Contributor
July 31, 2018

 am sorry but i didn't get it.

 

I have 7 required field in a create view, arround 15 differents create view, i have to had a condition on each required field to display . "Please check again, some required field are missing" instead of "customfield XXXXX is required"

it look to me a little anoying instead than overload a generic message ....

Moses Thomas
Community Champion
July 31, 2018

@Olivier MAZENStep by  step

 

  • On logged in  as JIRA administrator,  go to  the project workflow  for  this  issue type which  you want to  create  issue.
  • In the field configuration scheme  which the screen scheme  is using, check  the field configuration  and  make  these 7 fields optional.
  • Then go to  workflow  of the issue type  and then click  on the transition  in your case it is the create transition   add the validator by clicking  the validator link add validator > script validator > >  simple script  validator. You will   see examples by clicking show example after choosing simple script validator
  • Now just  need to  add a condition(groovy) depending on your needs

    See other examples here: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/validators/simple-scripted-validators.html
  • choose the field that needs to  be filled ,  enter your message" "Please check again, some required field is missing"
  •   Lastly  you  can  only manipulate  the message of one field in  the create transiton
  • If you  want to  manipulate  message for 7 fields  then it gets  complex( you will  have to  do it  hard coded with some groovy some how.

 

This is how far  i  can  explain i  hope this helps.

Best regards,

Olivier MAZEN
Contributor
July 31, 2018

Hello Thomas,

 

thanks for you reply , i get your point everytime you explain it to me.

 

As i said i want to handle the message generally i dont want to had a validator for each required field i have in my JIRA SD solution.

 

You get the point when you said 

  • If you  want to  manipulate  message for 7 fields  then it gets  complex( you will  have to  do it  hard coded with some groovy some how."

That my question: Some how ?

 

Appenrelty this is not something you can reach easaly, i will put it on the side from now.

 

Thank for yor time anyway.

Olivier

Suggest an answer

Log in or Sign up to answer