- 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-16-2021 11:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:01 AM
Hi Parnesh,
Does this looks correct?
arr = current.u_vendors.split(',');
var arrayUtil = new global.ArrayUtil();
gs.getProperty("sn_major_inc_mgmt.promotemajorincident");
//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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:10 AM
try this
arr = current.u_vendors.split(',');
var arrayUtil = new global.ArrayUtil();
var sysid = gs.getProperty("sn_major_inc_mgmt.promotemajorincident");
if (!arrayUtil.contains(arr, sysid))
{
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 12:10 AM
arr = current.u_vendors.split(',');
var arrayUtil = new global.ArrayUtil();
var val =gs.getProperty("sn_major_inc_mgmt.promotemajorincident"); //getting property value in variable
if (!arrayUtil.contains(arr, val)) //using this variable value to compare as per your logic
{
arr.push(contact);
}
current.u_vendors = arr.join();
}
var mim = new sn_major_inc_mgmt.MajorIncidentTriggerRules(current);
mim.approveMIC();
action.setRedirectURL(current);
}