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


#1

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?


#2

Hello,

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: ^
excludes:

js:
(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.');
            $('#addResultErrors').show();
            o.event.stopPropagation();
            return;
        }
    });
}

);[/code]

Regards,
Tobias


#3

Thank you so much!


#4

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?

Thanks,

Brian


#5

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.

Regards,
Tobias


#6

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


#7

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

Regards,
Tobias