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

No I did not write out the full thing.  I just used an onChange script to set a dummy value and then checked to see if that value was still there when the MRV Add form loaded.

 

But its simple code

//In an onChange for the department field
this.savedDepartment = newValue;

//In an onLoad script for the MRV
if(this.savedDepartment) {
   g_form.setValue("department", this.savedDepartment);
   g_form.setReadOnly("department", true);
}

 

IbrahimK4837164
Tera Contributor

To implement your task you need to use the onChange script. This script will automatically populate other rows with the same value that was selected in the first MRV row. First get the value selected in the first row. Then set the same value for all subsequent rows. You also need to restrict the ability to select other values in subsequent rows so that users can only select the value that was selected in the first row. This can be done using the onChange script.

yes this is what i am trying to do, but i cant workout the script to implement it.

all attempts on an onChange Script bases on the Department inside the MRV is not successful

 

 

 

Did the suggestion and code sample I gave you not work?

i am sorry to say but it didnt 😞