How to fetch price of a catalog item which can vary based on variable values

Subhajit Mukhe1
Kilo Expert

In my catalog form, there is a list collector where we can select multiple values and each value has a price that will add up to the price of the catalog item. This functionality is working fine. The catalog item price is increasing as per the value selection. But I need to make a variable mandatory and visible if the price exceeds 2500$ before form submission... 

Any idea how can I achieve this.

14 REPLIES 14

Mohit Kaushik
Mega Sage
Mega Sage

Hi Subhajit,

Did you try writing an onSubmit catalog client script?

something like this:

var price = g_form.getValue('price variable name');

if(price>2500);

{

g_form.setDisplay('variable name you want to make visible',true);

g_form.setMandatory('variable name you want make mandatory',true);

}

else

{

g_form.setMandatory('variable name you want make mandatory',false);

g_form.setDisplay('variable name you want to make visible',false);

}

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi,

 

I am not able to fetch the price. Thats where I am facing the issue. I have not created a variable for price.

Hi,

You need not create a new variable for price, it is getting calculated right once you select the items, then fetch that value only.

I think the value you can get by g_form.getValue('price');

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi,

 

Yeah I had tried that at first but could not fetch the value.

 

The catalog Client script:

find_real_file.png

 

The alert popup: (No value found)

find_real_file.png