why isn't this AFTER INSERT BR working

Richard P
Mega Guru

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

4 REPLIES 4

ramesh_r
Mega Sage

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

Not applicable

Hi Richard,

Checkout the following threads :

Creating a mail script that pulls over an attachment on a record

Thank you
Regards,
Ajay
find_real_file.png

www.DXSherpa.com

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,


Quickly change the order to 1000 of that BR and check it should work. 


Thanks,
Ashutosh Munot

Paul Curwen
Giga Sage

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. 

 

 

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul