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,

 

This won't work in Postman like this. I was asking to make a post call or create a ticket from servicenow that will trigger the rest call. 

In simple words you have your business on the incident table. When you create incident record it will trigger the rest call. 

Now if you go to System logs > system log > All. Filter Message field with "@Steve" and it will show you few logs there share those logs with me. 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Sharjeel,

Thank you, i have just been setting up another oauth profile, web messages, and new business rule for testing purposes. 🙂

I will provide a test and come back to you shortly.

Many thanks

Steve

Sharjeel,

Please see the attached error log, 

Many thanks

Steve

Steve,

 

I think the HTTP method you define 'Create Ticket' or somwhere in the end point has some problem. This is not related to changes we did for attachment thing. Lets confirm this by removing the if condition we placed and try then

 

Thanks,

Sharjeel 

Regards,
Muhammad

Megha Padale
Giga Guru

Hi,

Check this link

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/script/useful-scripts/reference/...

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.