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

How to implement UI Script

Hi all,

I’m a bit embarrassed to ask this question as I know for majority of you, this is quite elementary. Now risking everything, here goes my question…

I wanted to implement the UI Script I saw in this community about making Defect field mandatory when test result = Failed. I copy-pasted this script from Giuseppe & Giovanni…


(document).ready( function() { .subscribe(‘result_dialog.loaded’, ‘uiscript_require_defects’, function(o)
(’#addResultDefects’).prev().append(’ *’); }); .subscribe(‘result_dialog.validate’, ‘uiscript_require_defects’, function(o)
if (.trim(o.values.defects) == ‘’ && .trim(o.values.status_id) == 5)
(’#addResultErrors’).append(‘Field Defects is required when the status is Failed’); (’#addResultErrors’).show();

But when I test it, nothing happens. My failed test result can still be saved without a defect.
I’m assuming blank include and exclude will make the script available to all pages.
What am I missing?
You could probably can tell I have no idea how to do this. Hence my questions.
And hopefully someone could spare some time to walk me through on how to implement this. Our TestRail version is v6.2.3.1114 (if that gives any help).

Hope I could get some help soon.


This question was answered by @Jeremy Downing of TestRail support.
Jeremy said the working js will be uploaded to GitHub repository for other users to reference.