Possible to Evaluate three Catalog Variables in one onChange Catalog Client Script?

Paul Porter
Tera Expert

I've been struggling to get a Catalog Client Script to fire, in which I'm wanting to evaluate three different Catalog Variables, that when evaluated as true will fire off an alert message. The Catalog Client Script has no Variable Name chosen in the form (which I recognize may be part of the problem). It would need to work on both the Platform and the Portal, which I know can introduce more issues, becase I may need two Catalog Client scripts

I'm fairly certain that my meager coding skills have done little for my success here. All my research has proved inconclusive and I'm at a dead end. Looking for a little help or perhaps the unfortunate conclusion that one cannot evaluate changes to three different Variable answers in one onChange Catalog Client Script.

The script for:
UI Type = All

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    var var1 = g_form.getValue('travel_event_1_preferred_method'); // How do you plan to travel to your Event 1 destination?
    console.log("Preferred travel method is " + var1);
    var var2 = g_form.getValue('travel_event_1_booked_hotel_question'); // Did you book your own hotel for Event 1
    console.log("Booked own hotel answer for is " + var2);
    var var3 = g_form.getValue('travel_event_1_rent_car_question'); // Do you need a rental car for Event 1?
    console.log("Need a car rental answer for is " + var3);
    // Check the conditions for the specific answers
    if (var1 == '2' && var2 == 'No' && var3 == 'Yes') { //book own flts, not booking hotel &  renting a car
        alert('Please work with your Travel Arranger to book your hotel/car.');
    }
}

 

 

 



1 ACCEPTED SOLUTION

Vaibhav_Nikam
Tera Guru

Hi @Paul Porter ,

You can not access 3 variables in single onchange client script.

You can do it using below 3 ways:

1. you need to create separate onchange client scripts.
2.you can use the UI policy to where make the conditions as per requirement and in script you can add alert.

3. Use the onsubmit client script where you can check the values in variable and accordingly submit the form.


If my response finds helpful, please indicate its helpfulness by selecting Accept as Solution and Helpful.

Thanks,

Vaibhav Nikam

View solution in original post

5 REPLIES 5

Thank you. I hadn't even considered your option 2 yet. I was able to quickly implement option 2 and deploy. Thanks again!