Show field message on LIST collector variable based on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 11:39 AM
I have variable named called as "Environment" type of this variable is list collector , in this collector i have three values DEV, IST, PROD so whenever PROD is selected i want to show , show field message .
Please help me with this as this is very urgent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:01 PM
Hi @snow34
Check this:
function onChange(control, oldValue, newValue, isLoading) {
// Exit if the form is still loading
if (isLoading || newValue === '') {
return;
}
// Split the newValue into an array (List Collector returns a comma-separated list)
var selectedValues = newValue.split(',');
// Iterate over the selected values and show a message if 'PROD' is found
for (var i = 0; i < selectedValues.length; i++) {
var value = selectedValues[i].trim(); // Trim any extra whitespace
if (value == 'PROD') {
// Show an info message box on the 'Environment' field
g_form.showFieldMsg('environment', "You have selected the PROD environment.", 'info', false);
break; // Exit loop early if 'PROD' is found
}
}
}
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 08:43 AM
I tried this but no luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:36 PM
Seems there is a bug with ShowFieldMsg and ShowErrorBox. The older and prior Problems are seen here:
1. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727748
2. https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0675031
3. https://noderegister.service-now.com/kb?id=kb_article_view&sysparm_article=KB0782155
Maybe a KB Article might be on the way!!
Hope this helps!
Regards, Akash
Please mark it as helpful 👍 or Accept Solution ✔️ based on the response to your query.
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.