Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

[UI Script] Conditional formatting for cases


Based on this request:

» Gist here «

How to use:
]Define the rules in var rules (line 12). For each rule specify an expression and a class to add to the table row when expression is true. Note: in expression use this.fieldname, where fieldname is a system name of the field to be evaluated (see API reference)[/]
]Declare styles for the classes which you used in the rules. Remember that the class gets added to a

Review and remove the rules defined in the gist as example.

The script uses REST API, so make sure it is enabled in your installation. The styles should apply as soon as the cases are loaded, or whenever the table is recreated (e.g. another section is selected). The fact that conditional formatting is not applied to new/copied cases is a known issue (hopefully not critical for you — as I don’t wanna fix that too :))

Feel free to ask if anything works incorrectly.


Hey Paul

Thanks a lot, I updated the values I needed and it worked!
You rock! :slight_smile:



Gee, thanks :slight_smile: Glad it worked for you


Hello all,

Thanks for your posting and posting this UI script. While such UI scripts are really useful, I must also say that we cannot really recommend developing/using such complex scripts because they will most likely break with future TestRail versions (and may even cause conflicts with/break built-in TestRail features, e.g. in case of JavaScript errors). UI scripts are mainly intended to implement smaller features and e.g. hide smaller aspects in the UI that you don’t want/need. But building complex scripts will likely break at some point, and if there are issues in the scripts we also wouldn’t be able to help with this.


[UI Script][Plugin][PoC] TestRail plugins — working demo

Hello Tobias,

I completely agree that UI scripts are not in any way reliable, and a priori inferior to native functionality. However, I try to make my scripts as little impacted by potential changes as possible — for example, this one doesn’t even use the TestRail JavaScript functions, but a call to REST API (which mustn’t break, as it’s public stable API), and a routine to add classes to table rows, which, if anything changes, is very straightforward to adjust :slight_smile:

Besides, if anything breaks, I’ll get an email notification and look into it asap.

Smaller aspects are fine, but why not build something that improves the workflow? After all, it’s possible and it works so far :slight_smile:

P.S. Also I hope customers do understand that these (at least my) UI scripts are a community product, provided as is and with no warranty. They are free to examine, modify the scripts, learn from them (for what I leave the comments through the code), or choose not to use them at all. I just build them for fun and the sake of getting more comfortable with JavaScript and jQuery


Thanks for the update, Actine!



Someone else having problems with that script?
We run the newsest version von TestRail.


What kind of problems do you have, Daniel?


Nothing gets highlighted / formated.


It’s strange because I just checked and it works ok for me (on staging cloud instance, which is always last version).

A few suggestions:

  • Did you update TestRail recently? When TestRail is updated, UI scripts are automatically turned off, and one needs to enable them again.
  • Please check if REST API and session authentication for API are enabled — these are required for the script to fetch test case data.
  • If you still have issues, could you please share with me the UI script how you configured it? As explained in the first post, you need to define the rules and the styles yourself according to your requirements.

P.S. Also what browser do you use? Maybe there are some browser-specific compatibility issues I wasn’t aware of. Do you have any issues in JavaScript console when opening test cases page?


“…session authentication for API are enabled…” -> That did the trick. It was disabled before.

Thank you for the quick reply :smile:


No problem, glad it was just that :smile: . I should probably fix the instructions
(upd: nope, cannot edit the post anymore)