FujiForty - StringUtils

There are a few nice string utilities you might be used to using in the GlideStringUtils scriptable class. For my FujiForty followers I'm sure you know where this topic is going. You got it, it's not supported in ServiceNow Fuji application scopes.

Evaluator: java.lang.SecurityException: GlideStringUtil is not allowed in scoped applications
   Caused by error in script at line 1

==>   1: var GSU = new GlideStringUtil();

Most of the methods that were available are pretty basic and are easily replaced by standard JavaScript string methods, regex, or already covered by other scriptable classes. 

The most common complaints that I've heard of were related to the lose of base64 encoding and decoding support. These are typically used when working with binary data stored as strings.

The good news is these have been replaced by methods exposed in the GlideSystem ("gs") object which is available in all of your script environments. Here's a quick example showing the GlideStringUtil method usage as well as the app scope replacements. I also included the nil check replacement. The full collection of Fuji APIs still seem to be in the works and slowly growing so it's not yet clear what other GlideStringUtil methods might be available in other classes.

var s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

//var GSU = new GlideStringUtil(); //only supported in global

//var encodedS = GSU.base64Encode(s); //only work in global
var encodedS = gs.base64Encode(s);  //only works in scope
gs.debug(s + " : " + encodedS);

//var decodedS = GSU.base64Decode(encodedS); //only works in global
var decodedS = gs.base64Decode(encodedS);  //only works in scope
gs.debug(encodedS + " : " + decodedS);

//gs.debug(GSU.nil(s));
gs.debug(gs.nil(s)); //also works in global

//gs.debug(GSU.notNil(s));
gs.debug(!gs.nil(s)); //also works in global