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

[UI Script] - If "Case Type" is true


#1

We have some custom fields which only need to be visible if the Test Case Type = specific type. I’ve been struggling to isolate this element. I have no issues isolating it via Case Type ID or via the Case Type String.

Any direction would be great.

i.e.
function() {
if (uiscripts.context.user.role_id == 6 && )


#2

Hi Steve,

Thanks for your posting. I assume this would be for the case form when adding/editing/bulk-editing cases, is this correct? The UI script context is limited on the forms usually but you can get the current type ID directly from the form:

var type_id = $('#type_id').val();

Would this work for you?

Cheers,
Tobias


#3

Yeah. Sorry Should of gave it more context. What you provided would come in handy but I was looking Test/View where the field is already known.

I just want to hide some Test Case fields when the case type = certain type. So the testers can focus on the fields that matter to them and we can show certain custom fields under other scenarios.

Here is an example of our script

js:
$(document).ready(
    function() {
         if (uiscripts.context.user.role_id == 6){           
                $('table.io td:eq(5)').hide();
                $('table.io td:eq(7)').hide();
            }
}
);

Looking for it to

js:
$(document).ready(
    function() {
         if (uiscripts.context.user.role_id == 6 && <Casetype field == "Playtest">){           
                $('table.io td:eq(5)').hide();
                $('table.io td:eq(7)').hide();
            }
}
);

#4

Hi Steve,

Thanks for the additional details! The type details are also available on the view pages and the element can be looked up via the #cell_type_id ID. You can alternatively use TestRail’s API to load the case/test via JavaScript and this would include all properties in a structured format but the #cell_type_id approach would also work well and is much simpler.

I hope this helps!

Cheers,
Tobias