Forums

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

Show mandatory field labels in Red in Create/Edit screens

KL Kumar
Contributor
June 26, 2018

Hello,

I have a requirement to show mandatory field labels in Red in Create/Edit screens in Jira.

I believe we can manipulate the field labels using javascript. But my question here is - How do the system know that what are all the mandatory fields available in the screen just before the transition. Because, once we know the mandatory fields, then we can change the label color to red only for those mandatory fields.

For example: I am transitioning from screen A to screen B. In screen B, I have few system and custom mandatory fields (some of them are conditionally mandatory). So, while transitioning to screen B, immediately when the screen opens, all the mandatory fields labels should be in Red color.

 

Thanks for your help!

Kumar

1 answer

0 votes
KL Kumar
Contributor
June 28, 2018

So far in my investigation, I am able to get the mandatory field labels as Strings in Adaptavist Scriptrunner Behaviors script. But I am not able to turn these mandatory fields (both System and Custom fields) to Red color. Below is the code snippet I tried.

//  requiredFields has the list of mandatory field labels.

for(String field in requiredFields){
     field = field.trim()

     String js = "<script>\n"+
                         "AJS.\$(\"label[for="+field+"]\").parent('label').css('color','red');\n"+
                    "</script>"

     def FormField f = getFieldByName(field)
     f.setLabel(js)
}

 Any help is highly appreciated!

Thanks!

Suggest an answer

Log in or Sign up to answer