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

Which 3rd Application are you integrating with? is this another Servicenow instance or some other tool? 

- Sharjeel 

Regards,
Muhammad

Sharjeel,

Its another external third party service management ticketing tool. 

Kind regards

Steve 

Sharjeel,

So just to clarify I have a business rule that triggers to create an incident ticket in an external third party system over Oauth API endpoint. 

My business rule is triggered on assignment group and works correctly. The only piece now is to send any attachments of the created record in our system over to the third party external system.

Your assistance is much appreciated

Thanks

Steve

Hi Steve,

 

I have attached the updated script. encData object contains the base64 encoded string that you need to pass as a parameter of you endpoint. Please make sure to pass it in the right parameter. I am not aware of the end points you are using and which paramater is there for Attachments. As per my assumptions I passed it in AttachmentContent. I hope this will help.

 

Thanks & Regards,

Sharjeel  

Regards,
Muhammad

Sharjeel,

Thank you so much, I have just copied the script into the business rule and created an incident with excel attachment to trigger, which seems to have sent this file over the API, please see attached output. 

It seems as though the response was a scan of the document which was attached. 

I have attached the response, what do you think?

Thanks

Steve