Marcel Clemens
ServiceNow Employee
ServiceNow Employee

This forum is used as the digital learning experience Q&A for the K23 Scripting in ServiceNow Fundamentals pre-conference training. Please post your questions here and feel free to refer back to this article post knowledge. NOTE: This article will not be monitored post K23.

Comments
Kayla Doll
Giga Explorer

I have a specific question about the Syntax Editor Macros.  We have citizen developers at our company.  Additionally, all of Editor Macros are built in Global and all applications are scoped.  The citizen developers are only granted access to their scoped app.  They are unable to see the available editor macros to them.  We have to provide them with a "cheat sheet" to know what the macro names are and what they can do so they know what they can use in their app.  Is there a way for them to leverage the help and <Tab> key in this situation for the citizen developers to be able to see these in ServiceNow and not have to refer to an external cheat sheet.

Lisa Shuman
ServiceNow Employee
ServiceNow Employee

After doing some testing and investigation, to make all script macros available to all users is create a role (ie syntax_editor_macro), add the role to the module for access and create a read ACL for table syntax_editor_macro.

Lee Kraus2
Tera Guru

Hello!

 

Why is there a server side debugger and not one for client side? They seem to be similar (just trying to see how my code is running) but what makes them so different they can't both have something as robust as server side?

Lisa Shuman
ServiceNow Employee
ServiceNow Employee

Great question on debugging.  When you are working on the client side that is what is occurring in the browser and browsers have tools to do testing and debugging.  I found this great article on how you can debug on the browser side and discusses the differences between server and client-side debugging in ServiceNow. It also walks through an example of client-side debugging with the browser tools.

 

https://www.servicenow.com/community/now-platform-forum/how-to-debug-client-side-script-efficiently/...

 

 

 

Vijay Rajoli
Mega Explorer

I am in now

f_Rivers
Tera Contributor

How can we reverese engineer an EncodedQuery() ?

Lisa Shuman
ServiceNow Employee
ServiceNow Employee
Lisa Shuman
ServiceNow Employee
ServiceNow Employee

 

How to reverse engineer an encoded query:

Let's say this is the encoded query that you see in your code:

grProblem.addEncodedQuery("assigned_to=38cb3f173b331300ad3cc9bb34efc4d6^cmdb_ci=46babe48a9fe198101b9950e86f19ae1");

To reverse engineer to see what it does you need to encode the query before including it in the URL.  To do this you can go to: 

https://www.urlencoder.org/

Paste: ?sysparm_query=assigned_to=38cb3f173b331300ad3cc9bb34efc4d6^cmdb_ci=46babe48a9fe198101b9950e86f19ae1

Let the tool encode the string correctly for you and copy the new encoded line

In ServiceNow:

  • Go to Problem,>All, and in the URL after problem_list.do in the URL
  • Paste the encoded query that was from the urlencoder.org tool
  • Run the web page and your query should appear so you can see what the encoded query is doing.
kimreverman
Tera Guru

For GlideRecord with invalid query picking up the wrong records, what about using the system property glide.invalid_query.returns_no_rows set to true?

 

Lisa Shuman
ServiceNow Employee
ServiceNow Employee

There was a question on if you had to use the variables when writing your andOrCondition statements.  I ran the below code in a background script three different times and got the same records each time. As you can see you can concatenate statements and you do not have to use the variable for the queries.

 

//Test 1
var myObj = new GlideRecord('incident');
var q1 = myObj.addQuery('state','<',6);
q1.addOrCondition('state','>',2);
var q2 = myObj.addQuery("priority",1);
q2.addOrCondition("impact",1);
myObj.query();
while(myObj.next()){
var record = myObj.number+","+record;
}
gs.print(record);


//Test 2
var myObj = new GlideRecord('incident');
var q1 = myObj.addQuery('state','<',6).addOrCondition('state','>',2);
var q2 = myObj.addQuery("priority",1).addOrCondition("impact",1);
myObj.query();
while(myObj.next()){
var record = myObj.number+","+record;
}
gs.print(record);


//Test 3
var myObj = new GlideRecord('incident');
myObj.addQuery('state','<',6).addOrCondition('state','>',2);
myObj.addQuery("priority",1).addOrCondition("impact",1);
myObj.query();
while(myObj.next()){
var record = myObj.number+","+record;
}
gs.print(record);
Lisa Shuman
ServiceNow Employee
ServiceNow Employee
Lisa Shuman
ServiceNow Employee
ServiceNow Employee

If you are interested in more Instructor-led classes there is a community article updated every two weeks with classes available thru the end of the year.

 
Version history
Last update:
‎05-09-2023 09:40 AM
Updated by: