- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 05:57 AM
Hi
My first time trying out split.
I have made this business rule to trigger event, where I have a lot of values in a split.
parm1 = newValue and parm2 = oldValue
var newValue = current.u_action_date+"~"+current.u_onsite_date+"~"+current.u_hardware_delivery_from;
var oldValue = previous.u_action_date+"~"+previous.u_onsite_date+"~"+previous.u_hardware_delivery_from;
gs.eventQueue("Store_Remodelling-dates_changed", current, newValue,oldValue);
but I am having troble splitting it in the mail script, I have tried severel methods, but it ends up giving me a blank line, in the email, where the mail script line is.
My mail script looks like this
template.print("<br/> New Action date: "+current.newValue.split("~")[0]);
template.print("<br/> Old Action date: "+current.oldValue.split("~")[0]);
template.print("<br/> New Onsite date: "+current.newValue.split("~")[1]);
template.print("<br/> Old Onsite date: "+current.oldValue.split("~")[1]);
template.print("<br/> New Hardware Delivery date: "+current.newValue.split("~")[2]);
template.print("<br/> Old Hardware Delivery date: "+current.oldValue.split("~")[2]);
Am I doing it all wrong or...
Help or hints will be very much appreciated
BR, Dan
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 07:27 AM
1. Since current object is available in the notification email script, you don't have to pass it as a parameter in your event queue call. Instead, pass recipient as the 3 rd parameter
So, it should be,
gs.eventQueue("Store_Remodelling-dates_changed", current, recipeint,oldValue);
2. Edit your email script as follows,
var old_value=event.parm2;
var oldValSplitValues=old_value.split('~');
var old_action_date=new GlideDateTime(oldValSplitValues[0]); //initialize this variables as datetime to get the right date format
var old_onsite_date=new GlideDateTime(oldValSplitValues[1]);
var old_hw_del_date=new GlideDateTime(oldValSplitValues[2]);
Since new value is available in the current object, you could access it as follows,
template.print("<br/> New Action date: "+current.u_action_date);
Old value is saved in the local variables from the even parameter 2 above and called as follows,
template.print("<br/> Old Action date: "+old_action_date);
template.print("<br/> New Onsite date: "+current.u_onsite_date);
template.print("<br/> Old Onsite date: "+old_onsite_date);
template.print("<br/> New Hardware Delivery date: "+current.u_hardware_delivery_from);
template.print("<br/> Old Hardware Delivery date: "+old_hw_del_date);
Let us know in case of any clarifications.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 06:13 AM
Hi Dan,
please check the example in the thread below:
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 06:15 AM
Since you are passing parameters in your event, you need to call the parameters of the event and not new and old values of the current record. Replace current.newValue with event.parm1 and replace current.oldValue with event.parm2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 07:27 AM
1. Since current object is available in the notification email script, you don't have to pass it as a parameter in your event queue call. Instead, pass recipient as the 3 rd parameter
So, it should be,
gs.eventQueue("Store_Remodelling-dates_changed", current, recipeint,oldValue);
2. Edit your email script as follows,
var old_value=event.parm2;
var oldValSplitValues=old_value.split('~');
var old_action_date=new GlideDateTime(oldValSplitValues[0]); //initialize this variables as datetime to get the right date format
var old_onsite_date=new GlideDateTime(oldValSplitValues[1]);
var old_hw_del_date=new GlideDateTime(oldValSplitValues[2]);
Since new value is available in the current object, you could access it as follows,
template.print("<br/> New Action date: "+current.u_action_date);
Old value is saved in the local variables from the even parameter 2 above and called as follows,
template.print("<br/> Old Action date: "+old_action_date);
template.print("<br/> New Onsite date: "+current.u_onsite_date);
template.print("<br/> Old Onsite date: "+old_onsite_date);
template.print("<br/> New Hardware Delivery date: "+current.u_hardware_delivery_from);
template.print("<br/> Old Hardware Delivery date: "+old_hw_del_date);
Let us know in case of any clarifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2019 06:03 AM
Hi G Balaji
Thank you very much for the help. It worked perfectly.
Except for changing the gs.eventQueue, here i just kept what I had.
Br, Dan