- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 03:33 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2020 04:39 AM
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
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 12:56 PM
Sharjeel,
I just changed the word in the business rule
from: while (gr.next()){
to: if (gr.next()){
Although this has not worked. Did you mean to change this in the web services message instead, rather than business rule?
Thanks
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 01:20 PM
Steve,
No, while(gr.next()) was correct no need to change that.
if(gr.hasNext()) should wrap the lines which is sending the attachment content via Rest api. See a sample code below.
if(gr.hasNext()) {
r.setStringParameterNoEscape('AttachmentName', 'Attachment');
r.setStringParameterNoEscape('AttachmentContent', encData);
r.setStringParameterNoEscape('AttachmentDescription', '1');
}
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 02:26 PM
Sharjeel,
I updated the business rule and also added the parameters into the web services message, and then generated auto variables, however the message isn't being send when not attaching a Attachment.
are you sure that encData is without the quotes?
Thanks
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2020 02:42 PM
Steve,
Yes encData is variable that should be without Quotes. If without attaching attachment rest call is not being made then without looking into the actual code it would be hard to help.
The idea is to not execute those functions or lines which are related to Attachment thing. We need to put all those lines under if condition. So that until we have attachment those lines doesn't get triggered
Thanks & Regards,
Sharjeel
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:36 AM