Onchange client script - select box variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:02 PM
I want to create a onchange catalog client script for State/Market variable.
if the value of state/market is choosen as "texas" and value of Do you need to set it up as is "standard_tx"
I need to add option to care manager type/skills variable.
I created a onchange client script for variable - state/market , but its not working:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:19 PM
Hi,
Create a Catalog UI policy
Apply the condition
if the value of state/market is choosen as "texas" and value of Do you need to set it up as is "standard_tx"
and in the run scripts section try below code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:19 PM - edited 11-28-2023 08:33 PM
Hi @J_31 ,
As you already written the catalog client script, what's the issue with that.
add the alert() for newValue [ before if and inside If ] and check the selected value.
you can try with g_form.getValue(<state/market>); // replate the correct variable and add the alert for that.
Share the result, if its not working.
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:33 PM
Hi @J_31 ,
Ur script will not give u the desired result because it is running on change of the state/market variable & by that time for other variable "do u need to be setup as" is still empty so ur condition will never evaluate to true.
So the best option would be to create a UI policy as Shruti mentioned Or if u want to use onChange script then u need to create it on both the variables which is state/market & do u need to be setup as.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 08:43 PM
@Danish Bhairag2 Good catch, i didn't notice the onChange variable.
@J_31 , you have root cause , why this script is not working , you just need to replate the onChange variables
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var stateMarket = g_form.getValue("VariableName"); // replace the correct variable
if( (stateMarket =='texas' ) && (g_form.getValue("do_you_need_to_be_set_up_as") == "standard_tx")){
g_form.addOption('care_mgr_type', 'bx', "bexardemo");
}
}
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
