- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 12:31 AM
Hi all,
I have two catalog item that uses a variable set, the requirement on this variable set one variable to show two different message - I will need one Catalog item to show this message - g_form.showFieldMsg('asset_in_stock',"... Asset in Stock Message 1",'info'); and the other catalog item to show separate message - g_form.showFieldMsg('asset_in_stock',"... Asset in Stock Message 2",'info');
Is this possible?
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 07:58 PM
Hi Sam,
you need to use the syntax properly; updated script below: highlighted in bold you need to compare the variable each time
function onLoad() {
//Type appropriate comment here, and begin script below
var catalogItemSysId = g_form.getUniqueValue();
if(catalogItemSysId == 'sys_id' || catalogItemSysId == 'sys_id'|| catalogItemSysId == 'sys_id'|| catalogItemSysId == 'sys_id'){
g_form.showFieldMsg('asset_in_stock',"Asset in Stock Message 1",'info');
}
else if(catalogItemSysId == 'sys_id'){
g_form.showFieldMsg('asset_in_stock',"Asset not in Stock Message 2",'info');
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 07:58 PM
Hi Sam,
you need to use the syntax properly; updated script below: highlighted in bold you need to compare the variable each time
function onLoad() {
//Type appropriate comment here, and begin script below
var catalogItemSysId = g_form.getUniqueValue();
if(catalogItemSysId == 'sys_id' || catalogItemSysId == 'sys_id'|| catalogItemSysId == 'sys_id'|| catalogItemSysId == 'sys_id'){
g_form.showFieldMsg('asset_in_stock',"Asset in Stock Message 1",'info');
}
else if(catalogItemSysId == 'sys_id'){
g_form.showFieldMsg('asset_in_stock',"Asset not in Stock Message 2",'info');
}
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 08:11 PM
Great Thats working - still learning scripts :))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2019 12:44 AM
Maybe already something like this?
var catitemSysId = g_form.getUniqueValue();
var messageStr = '';
if(catitemSysId == 'some_sys_id_A') {
messageStr = 'Message A';
} else if(catitemSysId == 'some_sys_id_B') {
messageStr = 'Message B';
}
g_form.showFieldMsg('asset_in_stock', messageStr);
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field