How to Auto populate item prices in MRVS

jonsr20
Tera Expert

Hey everyone,

 

I have created a MRVS and am attempting to get the values to populate based on the selection. I have several items with different values, I am trying to get it to populate the depreciated_item_value variable with the cost for which ever item is selected. Then multiply that depreciated_item_value by the quantity and populate into the donation_value variable. I have tried a few catalog client scripts but am not having much luck, any help would be greatly appreciated! I will post some pictures for reference.

 

Thanks,

Jonathan

 

 

1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @jonsr20 

 

Refer below steps and configure your client scripts accordingly :

 

1. To Auto-populate Depreciated Item Value, make use of below Client Script :

 

AmitVerma_0-1718946393621.png

 

function onChange(control, oldValue, newValue, isLoading) {
    function getValue() {
        var value = g_form.getValue('donation');
        value = value.split('$');
        g_form.setValue('depreciated_item_value', value[0]);
    }
    if (isLoading || newValue == '') {
        getValue();
        return;
    }

    //Type appropriate comment here, and begin script below
    getValue();
}

 

2. To Auto-Populate Donation Value based on quantity change, make use of below On-Change Client Script :

AmitVerma_1-1718946507391.png

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   var quantity = g_form.getValue('quantity');
   var itemValue = g_form.getValue('depreciated_item_value');
   var donationValue = itemValue*quantity;
   g_form.setValue('donation_value',donationValue);
   
}

 

Output :

 

AmitVerma_2-1718946559690.png

 

AmitVerma_3-1718946573870.png

 

AmitVerma_4-1718946585165.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

Saloni Suthar
Mega Sage
Mega Sage

Hi @jonsr20 ,

 

Can you share your client scripts please? 

 

 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Amit Verma
Kilo Patron
Kilo Patron

Hi @jonsr20 

 

Refer below steps and configure your client scripts accordingly :

 

1. To Auto-populate Depreciated Item Value, make use of below Client Script :

 

AmitVerma_0-1718946393621.png

 

function onChange(control, oldValue, newValue, isLoading) {
    function getValue() {
        var value = g_form.getValue('donation');
        value = value.split('$');
        g_form.setValue('depreciated_item_value', value[0]);
    }
    if (isLoading || newValue == '') {
        getValue();
        return;
    }

    //Type appropriate comment here, and begin script below
    getValue();
}

 

2. To Auto-Populate Donation Value based on quantity change, make use of below On-Change Client Script :

AmitVerma_1-1718946507391.png

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   //Type appropriate comment here, and begin script below
   var quantity = g_form.getValue('quantity');
   var itemValue = g_form.getValue('depreciated_item_value');
   var donationValue = itemValue*quantity;
   g_form.setValue('donation_value',donationValue);
   
}

 

Output :

 

AmitVerma_2-1718946559690.png

 

AmitVerma_3-1718946573870.png

 

AmitVerma_4-1718946585165.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Thank you so much for your response, I got that to work! You guys are the best!!!

 

Thanks,

Jonathan