Record Producer MRVS (Multi Row Variable Set), hide specific field for specific Record Producer

Dominik21
Tera Contributor

I have MRVS, which is being used in multiple Record Producers. In new Record Producer I am working on, we need to use that MRVS, however one of the variables in this MRVS is not relevant for the new Record Producer and should be permamently hidden (only for that specific new Record Producer). This requirement applies to Service Portal form view and I need to hide this specific variable for both MRVS table that is diplayed on the form and in the Modal form. Is it possible to achieve this using OnLoad Client Script? It can be either Client Script applied to that new Record Producer or Client Script inside that MRVS. Ideally I would like to avoid creating duplicate MRVS for the new Record Producer, because the existing one has complex client scripts which I want to reuse. 

 

I have tried following code inside MRVS OnLoad Client Script to get Sys ID of parent Record Producer, and then hide that variable conditionally, however I am unable to retrieve parent Record Producer Sys ID:

g_service_catalog.parent.getUniqueValue(); // Console error "Not a method"

g_service_catalog.parent.sys_id; // undefined

g_form.getUniqueValue(); // returns Sys ID of MRVS, I don't see a way that this could be helpful in this case

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Dominik21 

you can do this to hide it when Modal opens but I don't think you can hide it on the form where all MRVS rows are shown

Use this

1) use a hidden text variable and store the value as "hidden". This variable will be only for your new Record producer

2) then use onLoad catalog client script which applies to MRVS variable set and access value of that outside variable within this script and hide it

function onLoad() {
    var val = g_service_catalog.parent.getValue("hiddenVariableName");
    if (val == 'hidden') {
        g_form.setDisplay('mrvsVariableName', true);
    }
}

With this approach you cannot hide it here

AnkurBawiskar_0-1737638041504.png

 

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

@Dominik21 

Hope you are doing good.

Did my reply answer your question?

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

@Dominik21 

Thank you for marking my response as helpful.

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

Dominik21
Tera Contributor

Hi Ankur. Hope you are well too. I marked your answer as helpful. That was actually a clever idea. Eventually I retrieved Sys ID of Record Producer from HTML link.

Concerning hiding columns in MRVS I learnt it requires DOM, so I abandon this idea. 

Thanks & Regards,

Dom