APIs provide classes and methods that can be used in scripts to define functionality. ServiceNow provides APIs as JavaScript classes. Like all rock hard ServiceNow developers we use this classes to create or modify out of the box functionality. Since the Calgary release the API classes were completely changed. As an example, back in the days we were using ‘Packages.com.glide.ui.SysAttachment’ but those are not available anymore.
It has now been changed from ‘Packages.com.glide.ui.SysAttachment’ to GlideSysAttachment. Since there is no documentation available about these classes it can be hard to retrieve all public options from a class. Don’t be told something is impossible. There’s always a way! Probably you haven’t figured out yet. If you use the following script in as a background script, it returns all public options.
gs.print("Object: " + retrieveMethods); // Returns an object.
for ( var objectName in retrieveMethods) {
gs.print(objectName); // Return all available methods.
}
Your result should look like this:
At this time we known that the GlideSysAttachment API has a write option which we can used to store attachments in a ServiceNow instance.
sa.write(‘table name’, ‘file name’, ‘content type’, ‘base64 value’);

