The Now Platform® Washington DC release is live. Watch now!
There are many hidden gems in ServiceNow which are undocumented for some reason or the other. One such thing is a interesting function that I found while looking into the script include 'StdChangeUtilsSNC', called applyEncodedQuery() of GlideRecord.
Let's just say you have a use case where you have a encoded query and want to create or update a record using it. Here comes applyEncodedQuery() to your rescue. Below is a quick sample on how you can use the function.
var filter = 'caller_id=javascript:gs.getUserID()^active=true^short_description=Test^state=2';
var records = new GlideRecord('incident');
records.initialize();
records.applyEncodedQuery(filter);
records.insert();
The above code creates a incident with caller, short description and state being 'In Progress'.
Note: Tested the function in global scope.
If you liked the content, please share, click helpful, bookmark or leave your valuable comments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.