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

@Ankur Bawiskar  

venkat_guthik_0-1738152044587.png

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;

________________________________________-

If RITM data coming in API call, we need to display the MRVS container.

venkat_guthik_0-1738152542822.png
If we are not receiving any RITM data in the API call, we need to hide the MRVS container on the record. the cross arked one we need to hide on the record.

venkat_guthik_1-1738152665227.png

 



 

@venkat_guthik 

you didn't share your client script which you configured as per script I shared

Share the screenshot of that client script configuration as well

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

@Ankur Bawiskar  please find the sclient script below

venkat_guthik_0-1738156640350.png

 

@venkat_guthik 

can you add alert and share what came?

also share the MRVS configuration?

I hope that MRVS is not being made mandatory. if it's then it cannot be set as hidden

if it's becoming mandatory then make it non-mandatory first and then hide

function onLoad() {
    var rritm = JSON.parse(g_form.getValue('previous_ritm_s').toString());
    alert('mrvs value is' + rritm); // what came here
    if (rritm.length == 0) {
        g_form.setDisplay('previous_ritm_s', false);
    }
}

 

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

@Ankur Bawiskar 
MRVS is not  mandatory one on form

venkat_guthik_4-1738159221885.png

MRVS configuration. Internal name: previous_ritm_s

venkat_guthik_5-1738159256387.png

 


when we are passing one RITM value in the API call

venkat_guthik_1-1738158675145.png

The Onload client script displaying Object value with the alert.

venkat_guthik_0-1738158614180.png
when we are passing the  null value also alert showing object value.

venkat_guthik_3-1738158912843.png

 

venkat_guthik_2-1738158864161.png