Need to make MVRS readonly based on variable selection

Abdul
Tera Contributor

I have a variable named Purchase type which has like 4 values and when i select one value which is Refinery Request, then a bunch of variables which are declared under variable set MRVS, like Quantity, Asset number. They all should be made read only and non mandatory.
I tried to use UI policy but it is not working

Please suggest.

 

Thanks  

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Abdul 

you can write onLoad catalog client script on MRVS and then use this logic
Note: I assume your purchase type variable is outside MRVS

function onLoad() {
	
    var variableValue = g_service_catalog.parent.getValue("purchaseTypeVariableName");

    // give correct value to compare here
    if (variableValue == 'Refinery Request') {
        // make your mrvs variables read only and non mandatory here

    }

}

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

View solution in original post

7 REPLIES 7

Chaitanya ILCR
Kilo Patron

Hi @Abdul ,

create a client script and use to make it read only (add your conditions and use the below line)

g_form.setReadOnly('YOUR MVRS Internal Name')

 

In this example I'm making the mvrs readonly onload of the form

ChaitanyaILCR_0-1756917567034.png

ChaitanyaILCR_1-1756917681040.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

if there are 11 variables in the variable set i need to make like 5 read only based on the selection of a normal variable outside the variable set can you please help me with that 

Hi @Abdul ,

 

Please go through the link mentioned in my first post, that will explain you what you can do and what will be the behaviour.

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct'. Thanks!

 

 

Bhuvan
Kilo Patron

@Abdul 

 

Follow this article to implement your requirement,

 

https://www.servicenow.com/community/developer-articles/disable-buttons-in-multirow-variable-set/ta-...

 

If this helped to answer your query, please mark it helpful & accept the solution. 

 

Thanks,

Bhuvan