
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 08:30 AM
Hello! I would like to display a message to the user when they select a specific choice in one of the variables.
As soon as they choose that choice, the message should be displayed.
The variable name is: would_you_like_to_add_update_or_remove_a_patching_record
The choice that should prompt the message is: update
I've tried the following code (and some others) on the Catalog Client Script but it is not displayed the message.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (!isLoading && control.name === 'would_you_like_to_add_update_or_remove_a_patching_record') {
if (newValue == 'update') {
g_form.showFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record', 'Update the fields that you would like updated, leave the field blank if no update is required.', 'info');
} else {
g_form.hideFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record');
}
}
}
Hoping someone can assist with the script.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 11:42 AM
Hi Justin,
You can troubleshoot this by adding an alert to see how the if statements are evaluating. There's no point in adding control.name in the first if, so I'd go back to the standard format like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'update') {
alert('update')
g_form.showFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record', 'Update the fields that you would like updated, leave the field blank if no update is required.', 'info');
} else {
alert('newValue='+newValue)
g_form.hideFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record');
}
}
This will show the value of newValue if it's not 'update' - if you're expecting that, maybe it's 'Update' or something else. In the future, do yourself a favor and keep the Catalog Item variable names short!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 11:42 AM
Hi Justin,
You can troubleshoot this by adding an alert to see how the if statements are evaluating. There's no point in adding control.name in the first if, so I'd go back to the standard format like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'update') {
alert('update')
g_form.showFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record', 'Update the fields that you would like updated, leave the field blank if no update is required.', 'info');
} else {
alert('newValue='+newValue)
g_form.hideFieldMsg('would_you_like_to_add_update_or_remove_a_patching_record');
}
}
This will show the value of newValue if it's not 'update' - if you're expecting that, maybe it's 'Update' or something else. In the future, do yourself a favor and keep the Catalog Item variable names short!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 03:45 PM
@Brad Bowman , this looks like it may be useful to me also. Before I dive in, can you tell me if this code will work in the Portal too?
Thanks,
~Paul