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

[UI Script] Make Comment field required on Add Test Result dialog


I saw that a UI script was given to require the Elapsed field required in the Add Test Result box. Can you give me one to make the Comment field required please?



Thanks for your posting. Sure, this is very similar to how you make the Version or Elapsed fields required:

[code]name: Make Comment field required
description: Makes the Comment field required on Add Result dialog
author: Gurock Software
version: 1.0
includes: ^

(document).ready( function() { .subscribe(‘result_dialog.loaded’, ‘uiscript_require_comment’, function(o)
$(’#addResultComment’).parent().parent().prev(‘label’).append(’ *’);

    $.subscribe('result_dialog.validate', 'uiscript_require_comment', function(o)
        if ($.trim(o.values.comment) == '')
            $('#addResultErrors').append('Field Comment is a required field.');




Thank you so much!


Hi - I assume with a couple changes the Defect field can also be made mandatory - correct?

Could a default value also be set within the script?




Hello Brian,

Thanks for your posting. Yes, this also applies to the Defects field and you just need to replace #addResultComment with #addResultDefects (and o.values.comment with o.values.defects). Depending on the TestRail version, you might also need to change the result_dialog.loaded handler a bit (e.g. with TestRail 4.0) and we are happy to look into this if you could us know your TestRail version. You should be able to set a default value as follows:

$.subscribe('result_dialog.loaded', 'uiscript_require_defects', function(o) { .. $('#addResultDefects').val('TR-100'); });

I hope this helps and I look forward to your reply.



Thanks Tobias - I will see if we want to go thru with it and go from there. :slight_smile:


You are welcome, Brian, and please let us know in case any questions come up :slight_smile: