- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 10:10 AM
Hello all, I have a choice list on a form in our Service Portal. After selecting a specific value in the choice list, I would like to have a message displayed that contains a URL link. Also, if the value is selected, I would like to prevent the user from being able to submit. Could you help out and let me know how this can be achieved?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 11:23 AM
Hi,
Create one onChange() Catalog Client Script on the required variable of your Catalog Item and utilize the below script.
UI Type: All
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_form.getValue('backend_name_of_choice_field>') == '<backend_value_of_choice>'){
var url = 'https://www.google.com';
g_form.addInfoMessage('<a href=' + url + ' target="_blank">Google</a>');
}else{
g_form.clearMessages();
}
}
Then create onSubmit() Catalog Client Script on your required Catalog Item and utilize the below code.
UI Type: All
function onSubmit() {
if(g_form.getValue('<backend_name_of_choice_variable>') == '<backend_value_of_choice>'){
g_form.addErrorMessage('Cannot submit with this choice.');
return false;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 10:40 AM
Hi,
Please try onSubmit Client Script.
if(g_form.getValue('your field name'=='option you want')){
g_form.addInfoMessage('you cannot submit with this value selected.' <a href = '/incident_list.do'>Click</a>);
return false;
}
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 11:23 AM
Hi,
Create one onChange() Catalog Client Script on the required variable of your Catalog Item and utilize the below script.
UI Type: All
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_form.getValue('backend_name_of_choice_field>') == '<backend_value_of_choice>'){
var url = 'https://www.google.com';
g_form.addInfoMessage('<a href=' + url + ' target="_blank">Google</a>');
}else{
g_form.clearMessages();
}
}
Then create onSubmit() Catalog Client Script on your required Catalog Item and utilize the below code.
UI Type: All
function onSubmit() {
if(g_form.getValue('<backend_name_of_choice_variable>') == '<backend_value_of_choice>'){
g_form.addErrorMessage('Cannot submit with this choice.');
return false;
}
}