Adding attachment script in Business Rule

SW7
Giga Guru

Hi Community,

I have a business rule attached that work for updating and creating incident tickets over API to external 3rd party, but I am now trying to add to the business rule the capture and sending of attachments, whenever there is an attachment. 

I successful created a test update and get and post of the attachments from Postman (with help of the document that Muhammad had previously sent through "HackLab") however was unsure of how to fit the script and which bits of script to add from the document

, however I am not sure of the JSON script i should be writing to be able get and send the attachments over externally from the business rule.

Just need to add to the business rule (not take away anything because it works fine for creating / updating of incidents) 

Any help much appreciated

Thanks

Steve

 

1 ACCEPTED SOLUTION

I am glad that you got it working. 

 

Just for your information, In case if you need to hit different endpoints based on Insert or update then you can create a script include reusable utility and from BR you can use

current.insert() & current.update() methods to check the operation and based on that you can call your script include passing in dynamic data. I hope this will help you in the future. 

Have a nice day 🙂 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

View solution in original post

40 REPLIES 40

Steve

Yes it looks good. Status code is OK we recieved response. Now you just need to confirm with the 3rd part tool team to validate. 

Please mark this correct & helpful if it answered your question.

Thanks & Regards,
Sharjeel

Regards,
Muhammad

Sharjeel,

Thank you, one last quick question, should this business rule be run before or after action?

 

Many thanks

Steve

Async Business rules are recommended in this scenario. As in your scenario you are not required to updated anything on the current incident once the call is made. 

Async business rules are similar to after rules in that they run after the database commits a change. Unlike after rules, async rules run in the background simultaneously with other processes. Async business rules allow ServiceNow to return control to the user sooner but may take longer to update related objects. 

Please mark this CORRECT & HELPFUL if it answered your question.

Thanks & Regards,
Sharjeel

 



Regards,
Muhammad

Sharjeel,

Thank you, I really appreciate the help. I ill test all this out tomorrow with a few test scenarios and also with the client and will let you know.

Many thanks again.

Steve

Steve,

Glad to be of help. if all works fine please be kind to mark my response as CORRECT and HELPFUL. 

Have a nice day 🙂 

Thanks & Regards,

Sharjeel

Regards,
Muhammad