- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2021 11:18 PM
Hi,
Below is a Ui action where INC when promoted to Major Inc, vendor filed should auto-populate. it is working fine except the else part has some issue when Manulife Internal is already present in the vendor filed it should not add it twice.
Can someone please suggest what can be done. Also, one of colleague said we should not hardcode SYS_ID and to use sys property instead. How to call it in this UI Action?
function promoteMIC() {
var arr = [];
var contact = "Manulife Internal";
var vendors = current.u_vendors;
if (global.JSUtil.nil(vendors))
{
current.u_vendors = contact;
} else {
arr = current.u_vendors.split(',');
var arrayUtil = new global.ArrayUtil();
if (!arrayUtil.contains(arr, "4affe5a4dbf89810075504c2ca961912")) {
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:26 AM
Hi Ankita,
update as this
function promoteMIC() {
var arr = [];
var contact = "Manulife Internal";
var vendors = current.u_vendors;
if (global.JSUtil.nil(vendors))
{
current.u_vendors = contact;
} else {
arr = current.u_vendors.split(',');
var value = gs.getProperty("sn_major_inc_mgmt.promotemajorincident");
var arrayUtil = new global.ArrayUtil();
if (!arrayUtil.contains(arr, value)) {
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}
Regards
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
02-17-2021 12:16 AM
Hi,
update as this
Changes in bold
function promoteMIC() {
var arr = [];
var contact = "Manulife Internal";
var vendors = current.u_vendors;
if (global.JSUtil.nil(vendors))
{
current.u_vendors = contact;
} else {
arr = current.u_vendors.split(',');
var value = gs.getProperty("sn_major_inc_mgmt.promotemajorincident");
var arrayUtil = new global.ArrayUtil();
if (!arrayUtil.contains(arr, value) {
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}
Regards
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
02-16-2021 11:57 PM
Hi
Have a look on this LINK which will help you to understand how to create and access property.
First create a property in sys_properties.list and then use below code in
Accessing a property in server-side script (Business Rules, UI Actions, UI Pages, etc.)
var propertyValue = gs.getProperty('your.property.name.here');
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks & Regards,
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:23 AM
Hi Ankita,
Below is the Syntax to call System property.
var val = gs.getProperty('name of the system property');
Regards,
Abdul Rahiman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:26 AM
Hi Ankita,
update as this
function promoteMIC() {
var arr = [];
var contact = "Manulife Internal";
var vendors = current.u_vendors;
if (global.JSUtil.nil(vendors))
{
current.u_vendors = contact;
} else {
arr = current.u_vendors.split(',');
var value = gs.getProperty("sn_major_inc_mgmt.promotemajorincident");
var arrayUtil = new global.ArrayUtil();
if (!arrayUtil.contains(arr, value)) {
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}
Regards
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
02-18-2021 03:42 AM
Hi Ankur,
Thanks!! After promoting inc to Major the vendor watchlist filed is not supposed to get locked but it is getting locked when i click on it. Can you please help me understand why is it happening so?