It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scripted custom field to included value based on priority

David Thompson Sep 22, 2013

Hi,

I'm trying to make a scripted filed return a value that will make the scripted field a colour based on the priority of the issue.

Bloker = red

Critical = amber

etc

This has been requested so it shows in the view issue screen so at a glance people know if it's important.

I have created the scripted field. I have been testing the code for it in the Admin "Script fields" section based on previewing issues etc but I keep bringing the instance down.

I thought this would be a start but I'm new to coding this and with crashing my test instance it'sa slow process.

Any pointers is much appreciated.

Cheers,

David

if(priority.equals("Blocker (P1)"))
{

return "{panel:borderStyle=solid|borderColor=#ccc|bgColor=#FF0000}
{color:white}*THIS IS A PRIORITY 1 ISSUE*{color}
{panel}";
}

else if(priority.equals("Critical (P2)"))

return "{panel:borderStyle=solid|borderColor=#ccc|bgColor=#FFCC33}
{color:white}*THIS IS A PRIORITY 1 ISSUE*{color}
{panel}";
}
 
else if(priority.equals("Major (P3)"))

return "{panel:borderStyle=solid|borderColor=#ccc|bgColor=#0000FF}
{color:white}*THIS IS A PRIORITY 1 ISSUE*{color}
{panel}";
}

else if(priority.equals("Minor (P4)"))

return "{panel:borderStyle=solid|borderColor=#ccc|bgColor=#009900}
{color:white}*THIS IS A PRIORITY 1 ISSUE*{color}
{panel}";
}

else (priority.equals("Trivial (P5)"))

return "{panel:borderStyle=solid|borderColor=#ccc|bgColor=#999999}
{color:white}*THIS IS A PRIORITY 1 ISSUE*{color}
{panel}";
}

1 answer

1 accepted

0 votes
Answer accepted
JamieA Sep 23, 2013

You need to return html, not wiki markup macros...

You can see what html those macros produce and then copy the html for them.

I don't really recommend doing this though - you will be better off with some javascript that colourises the rows in the dash or issue navigator according to the priority.

Also your script looks wrong, try:

if (issue.getPriorityObject.getName == "High") {
	return "/*html*/ High /*/"
}
else if (...)

David Thompson Sep 26, 2013

Hi Jamie,

Thanks for the reply, I went down the panel macro route as I'd got a custom field to display the colours required during testing. However if there is a more suitable method then I open to the suggestion. Do you have any links to the javascript method? as I agree having the issues coloured in the navigator is a nice option.

Thanks,

David

JamieA Sep 26, 2013

This highlights issues based on their RAG status which is in a label: https://gist.github.com/jechlin/6730220

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

scaling agile at the enterprise level with Valiantys

Hey there Community! My name is Vannya Vallejo, the Channel Communication Specialist at Atlassian and I want to help Atlassian users like you learn about our Solution Partners and how they can help ...

427 views 1 12
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you