To populate value from LookUpSelect Box variable from MRVS to single line text variable outside MRVS

Amrutha K V
Tera Contributor

Hi Team,

I have a LookUp Select Box variable named 'Plant' in PackSize MultiRow Variable set(MRVS). 
Have a Single Line Text variable named 'PlantOutside' in Outside MRVS. 
When user select a value for Plant from PackSize MultiRow Variable set, i want to autopopulate that value in my Single Line Text variable which is present outside MRVS.
I have tried the below OnChange Catalog Client script in PackSize MRVS level when the Plant variable changes,but i cannot able to set the value in single line text variable. Please help me 

Onchange of Plant inside MRVS:

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || !newValue)
        return;

    // newValue = AU01 - Australia Direct
    alert('Selected Plant:1 ' + newValue); -- > working 

    try {
        var parentForm = g_service_catalog.parent;

        if (parentForm) {
            alert('Selected Plant:2 ' + newValue); -->working
            //var plant = g_form.setValue('plantoutside', newValue);
            //var plant = parentForm.g_service_catalog.setValue('plantoutside', newValue);
            var plant = parentForm.setValue('plantoutside', newValue);
            alert('Selected Plant:3 ' + plant); -- > not working 
        }
    } catch (e) {
        console.log(e);
    }
}


Please help me to populate value in PlantOutside variable from Plant variable . 

Thank you




1 REPLY 1

Brad Bowman
Mega Patron

g_service_catalog does not (yet?) work to set values, you can only getValue.  You can use a script like this:

if (this) { //Service Portal method
	this.cat_g_form.setValue('v_manager', newValue);
} else { //native UI method
	parent.g_form.setValue('v_manager', newValue);
}

If you are using Service Portal / ESS, this script is also needed onLoad of the Catalog Item, not the MRVS:

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}