- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
New Scoped Classes
1. Console Class
The Console class introduces logging capabilities within scoped applications, making debugging and tracking easier.
Methods & Usage:
var console = new Console();
console.log("This is a log message");
console.info("This is an info message");
console.warn("This is a warning message");
console.error("This is an error message");
Additional Methods:
-
group()
: Creates a new inline group in the console log. -
groupCollapsed()
: Creates a collapsed inline group. -
groupEnd()
: Ends the current inline group.
Example:
console.group("Group Example");
console.log("Inside the group");
console.groupEnd();
2. Lead Class
The Lead class manages lead records within the ServiceNow Store.
Methods & Usage:
var lead = new Lead();
var newLead = lead.createLead("John Doe", "john.doe@example.com", "Sales Inquiry");
Additional Methods:
-
getLeadById()
: Retrieves a lead by ID. -
updateLead()
: Updates an existing lead. -
deleteLead()
: Removes a lead record.
Example:
var leadRecord = lead.getLeadById("123456");
leadRecord.updateLead({ status: "Converted" });
lead.deleteLead("123456");
Enhancements to Existing Scoped Classes
1. GlideRecord Enhancements
The GlideRecord class now supports additional query methods for better filtering of records.
New Methods:
var gr = new GlideRecord('incident');
gr.addNotNullQuery('short_description'); // Fetches records where short_description is not null
gr.addNullQuery('closed_at'); // Fetches records where closed_at is null
gr.query();
while (gr.next()) {
gs.info(gr.number + " - " + gr.short_description);
}
2. GlideSystem (gs) Enhancements
The GlideSystem (gs) class now includes Base64 encoding and decoding methods.
New Methods:
var encodedString = gs.base64Encode("Hello, ServiceNow!");
var decodedString = gs.base64Decode(encodedString);
gs.info("Encoded: " + encodedString);
gs.info("Decoded: " + decodedString);
Conclusion
The ServiceNow Yokohama release significantly improves the developer experience by introducing powerful new classes and enhancing existing ones. From advanced logging and lead management to improved querying and encoding, these updates equip developers with better tools for managing and extending ServiceNow applications.
For a comprehensive list of all API changes, refer to the Yokohama API Release Notes.
- 497 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.