- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 02:44 AM - edited ‎11-20-2022 03:04 AM
hello,
on the create new incident form, i have a list type field named "u_prev_callers"
i want to add each caller to the u_prev_callers list, without removing the previous caller.
so that once the caller field changes i can see all the history of the caller field.
im having trouble with the script
how can i manage to do that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 03:36 AM
Hi,
Please do not push the same user again.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var pre='';
var ccaller=current.getValue('caller_id');
if(current.getValue('u_prev_callers'))
pre=current.getValue('u_prev_callers').split(",");
if(previous.caller_id)
{
pre.push(previous.getValue('caller_id'));
}
var au=new ArrayUtil();
current.setValue('u_prev_callers',au.unique(pre).join(","));
})(current, previous);
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 02:56 AM
Hi @Lior Kaitel,
Can you share your scripts here? Also, I'm bit confused due to line -
i want to add each caller assigned to the caller field(caller_id) to the u_prev_callers list.
Please share the correct/meaningful requirement/question.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 03:07 AM
i tried with business rule:
(function executeRule(current, previous /*null when async*/ ) {
var caller_name = g_form.getValue('caller_id');
var ut = new GlideRecord("sys_user");
var gr = new GlideRecord("incident", getCaller);
function getCaller(gr) {
var caller_name = gr.caller_id;
}
var listArr = gr.u_prev_callers.toString().split(','); //creates an array of current List field values
listArr.push(caller_name);
gr.setValue('u_prev_callers', listArr.join(','));
gr.update();
current.caller_name.toString();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 03:36 AM
Hi,
Please do not push the same user again.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var pre='';
var ccaller=current.getValue('caller_id');
if(current.getValue('u_prev_callers'))
pre=current.getValue('u_prev_callers').split(",");
if(previous.caller_id)
{
pre.push(previous.getValue('caller_id'));
}
var au=new ArrayUtil();
current.setValue('u_prev_callers',au.unique(pre).join(","));
})(current, previous);
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2022 03:54 AM
Hi @Lior Kaitel ,
Please create before update business rule on incident table and apply the filter caller changes
and run below code it will work
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var callerid= previous.caller_id;
var arr=[];
arr.push(current.u_prev_callers);
arr.push(callerid);
current.u_prev_callers=arr.toString();
})(current, previous);
I hope this helps
Please mark my answer correct if this helps you
Thanks
Mohit