Jump to content

Colour coding based on Priority

Recommended Posts

Hello all,

I'm trying to modify our request list to colour each request based on priority. I've narrowed it down to be either in list_cr.htmpl and/or list_edit.js.

I've tried inserting a PDM_IF tag somewhere around line 337 on list_cr.htmpl. Problem is, I'm only stabbing in the dark whether I'm actually using proper syntax or even hitting a variable that exists. I tested with something like this:

<PDM_IF "$args.priority" >= "4">

do stuff here


Does nothing other than blanks the request list. I've been trying to pick apart the docs but I'm not getting something. Is there anyone that can point me in the right direction?


Share this post

Link to post
Share on other sites


you need to add fmtfunc to your priority lscol and add additional lswrite to fetch priority enum.

there would be something like this:

<PDM_MACRO name=lscol attr=priority fmtfunc=zPriClr>
<PDM_MACRO name=lswrite text="var zPriEnum = @{list.priority.enum:0}">

function zPriClr(val) {
	function zGetPriClr(enumVal) {
		switch (enumVal) {
			case 1:
				return "red";
			case 2:
				return "blue";
			case 3:
				return "green";
				return "black";
	rs.data("<span style='color:" + zGetPriClr(zPriEnum) + "'>" + val + "</span>");


Share this post

Link to post
Share on other sites

Thanks again for the reply. I had followup questions back when, but that post got lost in moderator limbo. I've got similar but different questions.

The code given was successful, however very inconsistent. What it appears to be doing is colouring the NEXT request's priority. So for instance (and hopefully this wont turn out like crap :) )

Request      |  Summary       | Status     | Last mod.  | Priority

SR:000001 - My first ticket - Open - New User - 3 ...

SR:000002 - My second ticket - Open - New user - 1 ...

SR:000003 - My third ticket - Open - New user - 3 ...


That's a poorly reproduced example of what our scoreboard would look like. With the given code, the priority of SR:000003 gets coloured red when it should be the one above with the priority 1. Ordinarily I'd do trial and error but this is production with a fair number of concurrent users. They get testy when I mess with the desk too much so I'm hoping to prevail on people who know better than I. Apologies for my idiot questions :)



Share this post

Link to post
Share on other sites

just swap priority get and display macros:

<PDM_MACRO name=lswrite text="var zPriEnum = @{list.priority.enum:0}"> // this one gets current priority
<PDM_MACRO name=lscol attr=priority fmtfunc=zPriClr // this one displays it

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...