- 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:27 AM
GlideAjax is not supported in server side scripts which is BR, it only works in client script which client side scripts.
SO you have to first move the code from current client callable script include to a server side script include, and call that from your business rule.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 03:30 AM
How can I do that,
I have removed the Client callable checkbox from client script
And how should I call the parameters

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 03:36 AM - edited ‎09-06-2023 03:37 AM
You will have to write a similar function to be consumed on server side.
In your client script i see two variables - attachment_sys_id and endpoint_url
so in your script include, create a new function
sendAttachmentServer: function(attachment_sysid, endpoint_url){
//your code goes here
}
now call this function from your BR as
var zsk = new zenderskSender();
zsk.sendAttachmentServer(attachment_sysid, endpoint_url)
Regards,
Vismit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 03:42 AM
And where I will pass the value of attachment sys id and endpoint url

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2023 03:58 AM
In your BR, remove line number 7 to 18
instead, put below:
var zdsk = new global.ZendeskAttachSender();
var response = zdsk.sendAttachment(attachmentSysId, endpointUrl);
Now, create a new script include (you can keep client callable as checked because you can still use this for calls from server side)
var ZendeskAttachSender = Class.create();
ZendeskAttachSender.prototype = Object.extendsObject(AbstractAjaxProcessor, {
sendAttachment: function(attachmentSysId, endpointUrl){
//your logic goes here
},
type: 'ZendeskAttachSender'
});
Let me know if this does not work.
Regards,
Vismit