- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 04:59 AM
Hi All,
How i can store multiple values in one varible and join with comma , by current sys_id i am getting two sysid i want store two sys_id in one variable ?
in ui action var sys_id = current.sys_id;// getting two sys_id want to join in one variable
var arr = [];
var SYSID = arr.join(',');
gs.addInfoMessage(SYSID);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2021 10:11 PM
I am already responding on this thread.
So if you think I answered your original question of setting the number field with the list of RITMs selected then mark my response as correct and close this question.
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
05-12-2021 05:36 AM
enhance as this
I assume u_type is also referring to sc_req_item table
var url = '/sc_task.do?sys_id=-1&sysparm_query=u_number=' + sysIds + '^u_type=' + sysIds;
So final script
sendCustomEmail();
function sendCustomEmail() {
var sysIds = g_list.getChecked().toString();
// give correct field name for u_type
var url = '/sc_task.do?sys_id=-1&sysparm_query=u_number=' + sysIds + '^u_type=' + sysIds;
top.location.href = url;
}
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
05-12-2021 05:54 AM
Hi Ankur ,
I have tried the code but it is not working like exactly what i told in screenshot1 you can see that in To it attaching the ritm sys_id . my requirement is in To field it will selected ritm.requested_for and in number it will store ritm number working as expected
script modified:
function sendCustomEmail() {
var sysIds = g_list.getChecked().toString();
var requested_for = [];
for(i=0;i<sysIds.length;i++){
var gr = new GlideRecord("sc_req_item");
if(gr.get(sysIds[i].toString())){
requested_for.push(gr.request.requested_for.toString());
}
//gs.addInfoMessage("EmailClient " + requested_for);
}
var url = '/sc_task.do?sys_id=-1&sysparm_query=u_number=' + sysIds + '^u_to_whom=' + requested_for;
top.location.href = url;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2021 06:19 AM
Try to update as this
function sendCustomEmail() {
var sysIds = g_list.getChecked().toString();
var requested_forArray = [];
for(var i=0;i<sysIds.length;i++){
var gr = new GlideRecord("sc_req_item");
if(gr.get(sysIds[i].toString())){
if(gr.request.requested_for){
requested_forArray.push(gr.request.requested_for.toString());
}
}
}
var url = '/sc_task.do?sys_id=-1&sysparm_query=u_number=' + sysIds + '^u_to_whom=' + requested_forArray.toString();
top.location.href = url;
}
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
05-12-2021 06:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2021 06:44 AM
Because you are doing GlideRecord in client side.
Can you share what came in the array?
Is the field name u_to_whom correct
function sendCustomEmail() {
var sysIds = g_list.getChecked().toString();
var requested_forArray = [];
for(var i=0;i<sysIds.length;i++){
var gr = new GlideRecord("sc_req_item");
if(gr.get(sysIds[i].toString())){
if(gr.request.requested_for){
requested_forArray.push(gr.request.requested_for.toString());
}
}
}
alert('array->'+ requested_forArray);
var url = '/sc_task.do?sys_id=-1&sysparm_query=u_number=' + sysIds + '^u_to_whom=' + requested_forArray.toString();
top.location.href = url;
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader