Hiding MRVS container based on variable value in MRVS

venkat_guthik
Tera Guru

Hi Community...
I got a requirement that, based on the inside variable value in MRVS, i need to hide the entire container,
For example, Iam having A,B,C,D variables in the MRVS container. Based on the input variable value we need to display the data in B,C and D. (here "A" is reference variable, BCD are text variables)
suppose if the value of A='empty or 'null', no need to display the other variables and also the MTVS container need to hide on the form. (entire container need to hide).
If "E" is external variable (outside the container) means, based on that we can hide the MRVS container, But this variable "A" is inside the MRVS container.
I have tried with the catalog UI polocy and catalog client script, but no luck.

Please help any one, how can i achive/implement this fucntionality please suggest.

1 ACCEPTED SOLUTION

@Ankur Bawiskar Hi ANkur, I have seen your other thread reply in the community regarding the same scenario.
https://www.servicenow.com/community/developer-forum/hide-variable-column-from-multi-row-variable-on...

DOM manipulation suggested by you. Is it good to implement this or not ?
Please let me know

View solution in original post

19 REPLIES 19

booher04
Tera Guru

Are you saying that you have a MRVS called "something", inside of this you have 4 variables called "A", "B", "C", and "D".  The user selects a record in "A" called "null", you want the entire MRVS("something") to then be visible = false? Meaning A, B, C, D are all hidden?

venkat_guthik
Tera Guru

@booher04 Hi
Yes.
It is an automated functionality. we will create request/ritm through API call. The RITM will contain MRVS container to populate the data.
Whenever we are retrieves the "A" value in the MRVS, other BCD values will populate in the MRVS based on the "A" value. For this we are using before insert business rule to populate BCD values.
Suppose, if we not get any value  for "A" means, the MRVS shows empty on the request.
Instead of showing empty MRVS container, customer wants to hide the entire MRVS container whenever we will not receive "A" value. (this "A" B,C,D all four variables are inside the container only)

How to hide the MRVS container if its having empty/null data inside it.
Please suggest anyone, how can i go forward to achieve this.

Ankur Bawiskar
Tera Patron
Tera Patron

@venkat_guthik 

so you are populating the rows in MRVS based on some script when API call is made to ServiceNow?

If yes then during populating/create rows via script check if variable A has value, if yes then only add that row

This ensures whenever MRVS is opened on RITM it has rows where variable A has value in it

Please share some screenshots as well and script which you are using.

Your question seems confusing. You are saying A is external variable but you are also saying A,B,C,D are variables within the MRVS?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

venkat_guthik
Tera Guru

@Ankur Bawiskar  Hi Ankur,
Yes, we are populating the rows in MRVS, when API call is made to ServiceNow.
We are using Before insert business rule on RITM table and updating the MRVS with the below script.

        var mrvs1 = current.variables.previous_ritm_s; //previous_ritm_s is the MRVS name
        var rritms = JSON.parse(mrvs1);
        var ritmCnt = rritms.length;
        for (var i = 0; i < ritmCnt; i++) {
            var ritm = rritms[i];
            var reqItem = new GlideRecord("sc_req_item");
            reqItem.get(ritm.ritm_number);
            ritm.ritm_number1 = reqItem.number;
            ritm.ritm_state = reqItem.state.getDisplayValue();
            ritm.status = reqItem.approval.getDisplayValue();
            ritm.due_date1 = reqItem.due_date;
            }
            current.variables.previous_ritm_s = rritms;


The below screenshot will provide you in detail. MRVS name: Previous RITM's.
we are having total 4 columns as below(RITM Number, Status, Due date, Approval status)

venkat_guthik_0-1738146594533.png

whenever we will receive the 1st column value(RITM number), based on that remaining values will populate related to that RITM in next fields using above business rule.
If we are not getting the RITM value, the container should be like below

venkat_guthik_1-1738146826108.png

But, Our customer requirement is, when we are not getting any RITM's in the MRVS, we need to hide the entire container(no need to display the MRVS if it is empty).

I have written catalog client script Onload on catalog form like below, It is hiding the MRVS container completely on the form, but not checking the RITM null value condition(hiding for both empty/non empty ritm values).

venkat_guthik_2-1738147981241.png

 

function onLoad() {
 var rritm = g_form.getValue('ritm_number');
 if (rritm == ' ' || rritm == 'null') {
 //g_form.setVisible('previous_ritm_s', false);
 g_form.setDisplay('previous_ritm_s.status', false);
    }

Please suggest where iam missing and how can i achieve this hiding entire MRVS container if we get only null values.