The CreatorCon Call for Content is officially open! Get started here.

How to Limit a Reference Variable in an MRV for the same value selected in the first Row

Peter Williams
Kilo Sage

good morning everyone,

so i have a trick request to configure,

i have an MRV with a reference variables that is looking up on the cmn_department table

 

i want to have the ability to auto fill the other row users will select with the same value they selected in the first row of the MRV.

 

Example:

 

the Department Column u selected Office Expenses

 

PeterWilliams_0-1712240365919.png

 

i want every other row to only show Office Expenses and not have the users be able to select anything else but Office Expenses base on their first row

so all other rows will only have the Office Expense and nothing else

 

is this possible with an onChange script?

 

1 ACCEPTED SOLUTION

maroon_byte
Mega Sage

Consider having Department variable outside of your mrvs in the form as well.. After the user selects this form Department variable and is adding first mrvs row, use onLoad script within mrvs to set the read-only mrvs Department field using below script:

 

var dept = g_service_catalog.parent.getValue('department');
    g_form.setValue('mrvs_dept', dept);

View solution in original post

21 REPLIES 21

DrewW
Mega Sage

Sounds like you need to create a client onLoad script that will look at the values in the MRV and populate the field and make it read only so they cannot change it.

 

this is correct, the first value in the department [0] will determine the other department fields values > [1] in the array set

So you should just need to get the value of the variable and use JSON.parse to convert it to an object and from there is should be easy to do.

i am trying it but no success, any suggestion on how to write out the script for it?