Auto fullfill MultiRow Variable Set (MRVS)

Facundo Prado
Tera Expert

Hello Everyone! I have a question about MRVS.
I have this Record Producer, and when this "reason of payment" field is "account payables" or "T&E", I need to autofill all variables on MRVS with a "0" or "1" (doesn´t matter if is 0 or 1).

The MRVS name is "booking_details".

FacundoPrado_0-1706186558984.png

 

FacundoPrado_1-1706186571171.png

Anyone has done something similar?

 

Thanks

 

1 ACCEPTED SOLUTION

Hi @Facundo Prado 

In addition to Brad's comment, let's try to modify line 14 and 15 in your script.

From

 

var mrvs = '[{"sap_booking":"1","profit_centre":"1"}]';
g_form.setValue("booking_details", mrvs);

 

To

var mrvs = [{"sap_booking":"1","profit_centre":"1"}];
g_form.setValue("booking_details", JSON.stringify(mrvs));

 

Cheers,

Tai Vu

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

You can use an onChange Catalog Client Script that applies to the Catalog Item when the "reason of payment" variable changes.  Your script would look something like this, depending on your variable names and the select box actual values:

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (g_form.getValue('reason_of_payment') == 'account payables' || g_form.getValue('reason_of_payment') == 'T&E') {
        var mrvs = '[{"variable_name_1":"0","variable_name_2":"0"}]';
	g_form.setValue("mrvs_internal_name", mrvs);
    }
}

 

Is not working. I´ve just tried some other things, but I cannot figure it out.

FacundoPrado_0-1706191624170.png


We used to use the JSON.parse() to call and read the MRVS, but we cannot use JSON on OnChange client script

Hi @Facundo Prado 

In addition to Brad's comment, let's try to modify line 14 and 15 in your script.

From

 

var mrvs = '[{"sap_booking":"1","profit_centre":"1"}]';
g_form.setValue("booking_details", mrvs);

 

To

var mrvs = [{"sap_booking":"1","profit_centre":"1"}];
g_form.setValue("booking_details", JSON.stringify(mrvs));

 

Cheers,

Tai Vu

Great!!! It worked... So, I need to change it to an OnSubmit client script... It could be that the JSON is not supported on an OnSubmit?

 

FacundoPrado_0-1706196389446.png