BR not running using GlideSysAttachment();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:35 AM
I have written an after BR on incident table, but it is not working. Please help -

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:57 AM
The second line in your code will not be defined as you are instantiating an object (gr) in line number 1. But gr won't hold any value with it. So gr.sys_id will not be defined. You would need to query the sys_attachment table first before continuing forward.
Regards,
Vismit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 01:01 AM
Hi @surbhi_123 ,
The query(); is missing after the gliderecord. can you try with the below code
(function executeRule(current, previous /*null when async*/ ) {
try {
// Replace 'your_condition_here' with your attachment retrieval criteria.
var gr = new GlideRecord('sys_attachment');
gr.addQuery('your_condition_here');
gr.query();
if (gr.next()) {
var attachmentSysId = gr.sys_id;
var file = gr.file_name;
var type = gr.content_type;
var apiEndpoint = 'https://******/api/v2/uploads?filename=' + file;
gs.log('The API endpoint is: ' + apiEndpoint);
var r = new sn_ws.RESTMessageV2('Cyber IAM_Zendesk Integration', 'Get token');
r.setEndpoint(apiEndpoint);
r.setRequestHeader('Content-Type', type);
// Assuming you want to send the attachment as the request body.
r.setRequestBodyFromAttachment(attachmentSysId);
var response = r.execute();
var responseBody = response.getBody();
gs.log('responseBody from BR: ' + responseBody);
}
} catch (ex) {
gs.error("Error in BR: " + ex.getMessage());
}
})(current, previous);
- replace "your_condition_here" in the line 5 eg: state=available
Please mark this as helpful and correct answer, if this helps you
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 02:32 AM
It is still not running. I am putting a log in line 2 to check if this BR is running or not, and no logs is found. I am writing after BR on incidnet table and no conditions are there in br

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 02:46 AM
In this case, there might be a mismatch between the BR when to run condition and the actual testing simulation that you are performing.
Regards,
Vismit