Change Table color according ticket time status

You can color buttons depending on minutes by using Automation Scripts.

I created a script with fn handler.

function getColor(minutes){
  if(minutes > 60) 
    return 'red';
  if(minutes > 30)
    return 'coral';
  if(minutes > 15)
    return 'orange';
  return 'green';
}

… and updated State Format to call fn.getColor function to get color for specific minutes.

This is the state display format I’ve used. It both displays colors and minutes.

<background {CALL:fn.getColor('{ENTITY STATE MINUTES:Status}')}>$1<br/>{ENTITY STATE MINUTES:Status}</background>

For production use you can prefer to use this format to reduce database queries. It will only update button colors.

<background {CALL:fn.getColor('{ENTITY STATE MINUTES:Status}')}>$1</background>

If you need more info about formatting table buttons you can read this tutorial.

4 Likes