Making custom field text red?

How to make custom field text red?

<script type="text/javascript">
AJS.$("#customfield_11329").attr('style', 'color:red')
</script>

Above code does not work. Any ideas?

2 answers

1 accepted

This widget could not be displayed.

In that way it does't work on 5+ jira version, try with this

&lt;script type="text/javascript"&gt;
jQuery(document).ready(function($) {
	JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {		
		callFunction();
	});
		callFunction();
	function callFunction(){  		AJS.$('label[for=customfield_11329]').css({color:'red'});
	}
});
&lt;/script&gt;

Great. It works!!

But only in edit screen, not in view screen.

glad to hear it worked!!

if it to be work on view screen you need to check custom field id on view screen

if my answer helped then vote up and accept as answerd :)

This widget could not be displayed.

try with this

AJS.$('label[for=customfield_11329]').css({'color':'red'});
or
AJS.$("#customfield_11329").parent('label').css('color','red');


Does not work!!!

<script type="text/javascript">
AJS.$("#customfield_11329").parent('label').css('color','red');
</script>

how you tried and whatis the jira version?

can you share your code? i tried now it is working

It is 5.1.5 version,

Still not working

@Rambanam Prasad In which file do I need to edit this?

@Joe Moreno you no need to edit any files, just add code in accepted Answer in Announcement banner for testing, once it worked as expected then i suggest to add this code as web resource module in a plugin(you will get lot of post on this forum if you need to know how to add it in plugin) Note: don't forgot to change customfield id :)

@RambanamP I have similar requirement where I need to change the mandatory field labels in Red. But here I am using ScriptRunner Behavior script and it is not working. Here is my code snippet.

// requiredFields has the list of mandatory fields labels.

for(String field in requiredFields){
field = field.trim()
log.warn("Field ::"+field)

String js = "<script type=\"text/javascript\">\n"+
"jQuery(document).ready(function(\$) {\n"+
"JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {\n"+
"callFunction();\n"+
"});\n"+
"callFunction();\n"+
"function callFunction(){\n"+
"AJS.\$('label[for="+field+"]').css({color:'red'});\n"+
"}\n"+
"});\n"+
"</script>"

log.warn(js)
def FormField f = getFieldByName(field)
f.setLabel(js)

Any help is highly appreciated.

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
callFunction();
});

callFunction();

function callFunction(){
AJS.$('label[for=customfield_11329]').css({color:'red'});
}
});
</script>

add above code on announcement banner by changing cusotmfield id

 

am not sure how to include javascript using behavior. 

@RambanamP Thank you. This works well for custom fields. Can this be possible for system fields? I want to show system fields also in Red.

yes, just you need to change replace customfield id with system field id

 

<script type="text/javascript">
jQuery(document).ready(function($) {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
callFunction();
});

callFunction();

function callFunction(){
AJS.$('label[for=summary]').css({color:'red'});
AJS.$('label[for=components]').css({color:'red'});

}
});
</script>

@RambanamP Thank you!

It works...

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

135 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you