- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 07:18 AM
Also what is the difference between
var StringUtil = new GlideStringUtil();
and this?
var StringUtil = GlideStringUtil ;
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 04:35 AM
Well prasanna,
GlideStringUtil is a global variable, its not a class. See Download Attachments as a ZIP File - ServiceNow Guru
To use GlideStringUtil:
var StringUtil = GlideStringUtil;
var sa = new GlideSysAttachment();
var binData = sa.getBytes(current);
var encData =StringUtil.base64Encode(binData);
There are a lot of useful functions in GlideStringUtil. These are:
--
Cheers,
AR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 12:26 PM
Hi Prasanna,
Can you help me understand exactly what you are trying to do or was this just out of curiosity because you said GlideStringUtil() used somewhere?
There are a lot of useful (and documented) string utilities available in JSUtil(). I use them all the time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 03:47 AM
attachScreenshot: function() {
gs.log('inside function 29692');
var StringUtil = new GlideStringUtil();
var value = StringUtil.base64DecodeAsBytes(this.getParameter('sysparm_value'));
var tableName = this.getParameter('sysparm_tableName');
var sys_id = this.getParameter('sysparm_sys_id');
var filename = this.getParameter('sysparm_filename');
var content_type = this.getParameter('sysparm_content_type');
var attachment = new GlideSysAttachment();
var x = new GlideRecord(tableName);
x.addQuery('sys_id',sys_id);
x.query();
gs.log(x.number +'29692');
attachment.write(x, filename, content_type, value);
gs.log(x.number +'x'+ filename +'filename' +content_type+'content_type 29692');
return ('Screen shot attached to ticket!');
}
Just trying to implement this function.. ! Not sure what goes wrong.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 03:53 AM
Thank you for the details Prasanna. I am following up with our people...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 04:06 AM
got this working by correcting 13-15 as below (as x was not the record object and was a gliderecord object)
if(x.next()){
var attachment = new GlideSysAttachment();
gs.log(x.number +'29692');
attachment.write(x, filename, content_type, value);
gs.log(x.number +'x'+ filename +'filename' +content_type+'content_type 29692');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 04:35 AM
Well prasanna,
GlideStringUtil is a global variable, its not a class. See Download Attachments as a ZIP File - ServiceNow Guru
To use GlideStringUtil:
var StringUtil = GlideStringUtil;
var sa = new GlideSysAttachment();
var binData = sa.getBytes(current);
var encData =StringUtil.base64Encode(binData);
There are a lot of useful functions in GlideStringUtil. These are:
--
Cheers,
AR