why isn't this AFTER INSERT BR working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 05:53 AM
I have a working script which copies attachments from the inbound mail "after insert" however it wont work on insert...works fine if I change it to "update" but I dont want it at update, I want it on insert!
proved the script works fine, so its not that...its the trigger
var gr = new GlideRecord('sys_email');
gr.addQuery('uid', current.variables.attachment_id);
gr.query();
while(gr.next()) {
GlideSysAttachment.copy("sys_email", gr.sys_id, "sc_task", current.sys_id);
}
if I put in on an "update" works fine, pulls the record.
the BR should fire "AFTER insert", which means the current.sys_id is valid in the GlideSysAttachment.copy("sys_email", gr.sys_id, "sc_task", current.sys_id); line, the same as it is when I run it on update (i put it on update to prove the point, its not intended to stay there).
So can anyone advise what I'm missing here?
Cheers
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 06:03 AM
Hi Rrichard,
There are two option
1 . Create "AFTER insert" BR only but you need to make wait BR execution for sometime (Ex : 30 sec)
OR
2. Create workflow on the same table and give first activity as timer (Timer should be 30 sec) then Run script action in second activity and use your script in Run Script
Thanks
Ramesh R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 06:16 AM
Hi Richard,
Checkout the following threads :
Creating a mail script that pulls over an attachment on a record
Thank you
Regards,
Ajay
www.DXSherpa.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 06:45 AM
HI,
Quickly change the order to 1000 of that BR and check it should work.
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2018 09:01 AM
Hi,
Looks like a timing issue so:
Insert gs.sleep(30000) in the first line of your onAfter function. This will make it wait 30 secs until it runs.
Regards
Paul