- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 03:20 AM
I have a onLoad Client Script on incident table which takes hard-coded values-
It calls the Script include -
The sys id in the client script is of the attachment added to the incident table, but it is hardcoded. To make it dynamic I wrote the same thing in BR. I wrote the BR on attachmet table as follows -
But it gives error as -
How to correct this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 03:48 AM
Its better to use new script include :
Business Rule
var attachmentSysId = current.sys_id; //will pass in function parameter
var apiEndpoint = 'your link'; //will pass in function parameter
var si = new ZendeskSender(); //Script include
//store return value to use further
var getReturnValue = si.sendAttachment(attachmentSysId,apiEndpoint); // function
//do your activity
Script include :
sendAttachment : function (attachmentSysId , apiEndpoint) {
var attachment = new GlideSysAttchment();
//below code will be same as per your existing code
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 03:30 AM
Hello @surbhi_123 ,
You need to create new function in Script include and directly call that function in Business rule & no need to use GlideAjax
You can adjust the code in script include to run for business rule.
e.g .,
var si = zenderskSender(); // name of script include
si.sendAttachment(); //function name
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 03:34 AM
and how can I pass the attachment sys id and content type to the script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 03:48 AM
Its better to use new script include :
Business Rule
var attachmentSysId = current.sys_id; //will pass in function parameter
var apiEndpoint = 'your link'; //will pass in function parameter
var si = new ZendeskSender(); //Script include
//store return value to use further
var getReturnValue = si.sendAttachment(attachmentSysId,apiEndpoint); // function
//do your activity
Script include :
sendAttachment : function (attachmentSysId , apiEndpoint) {
var attachment = new GlideSysAttchment();
//below code will be same as per your existing code
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates