- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 06:21 PM
Hi,
Before submitting the catalog item i want to see some alert message on top.
I am having a catalog item into that if Category= Undefined - did not find my issue type
Sub category= Undefined - did not find my issue type
Issue type= Undefined - did not find my issue type
then submit the item i want to show some alert message to the user which is
"Please check all categories before proceeding if it is undefined."
Alert message should show only category, sub category and issue type is Undefined - did not find my issue type
Please help me out on the same.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 11:21 PM
Hi @kranthi2
Replace your code with this:
function onSubmit() {
var category = g_form.getValue('u_category');
var subCategory = g_form.getValue('u_subcategory');
var issueType = g_form.getValue('u_issue_type');
// Check if any of the fields is undefined
if (category === 'undefined' || subCategory === 'undefined' || issueType === 'undefined') {
// Display alert message
alert("Please check all categories before proceeding if it is undefined.);
return false;
}
return true;
}
Please Mark this as Helpful and Accepted. If this Solves your query
Regards,
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 11:32 PM
the alert is returning correct value.
Now you need to check if you are comparing the correct values in your IF statement
if yes then that confirm box will show
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 11:38 PM
Yes i am comparing the correct values.
But i want to see alert message as "Please check all categories before proceeding if it is undefined- did not find any issue type"
But it is showing only "undefined- did not find any issue type"
Please help me out on the same do i need to modify anything ?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 11:21 PM
Hi @kranthi2
Replace your code with this:
function onSubmit() {
var category = g_form.getValue('u_category');
var subCategory = g_form.getValue('u_subcategory');
var issueType = g_form.getValue('u_issue_type');
// Check if any of the fields is undefined
if (category === 'undefined' || subCategory === 'undefined' || issueType === 'undefined') {
// Display alert message
alert("Please check all categories before proceeding if it is undefined.);
return false;
}
return true;
}
Please Mark this as Helpful and Accepted. If this Solves your query
Regards,
Deepak Sharma