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

Sharjeel, Do you have time to take a look at my setup and advise with regards to the attachment script, which doesnt appear to be sending correctly? Many thanks Steve

Hi Steve,

 

Please find attached. I have updated the Business rule. Please test and let me know if you face any issues. 

 

Thanks & Regards,

Sharjeel

 

Regards,
Muhammad

Sharjeel,

Thank you, is there a way to quickly test this out without involving the external party?

 

Many Thanks

Steve

Steve,

 

It would be hard but right after the below line in your script

 var httpStatus = response.getStatusCode();

add these line

gs.info("@Steve Response - " + responseBody);
gs.info("@Steve StatusCode - " + httpStatus);

 

make a post call. go to logs and see what you received there and share me the screenshot of logs. 

 

Thanks & Regards,

Sharjeel

 

 

Regards,
Muhammad

Sharjeel,

Thank you, please find the results of the postman test.

Kind regards

Steve