New Features in Washington DC Release(New scoped classes)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2024 09:44 PM
Introduction
The latest Washington DC release introduces new products and enhanced features across existing products in ServiceNow. Here’s a detailed overview of the new scoped classes and additional methods that have been added:
1. GlideAggregate - Scoped
Overview: GlideAggregate allows for database aggregation queries within ServiceNow. The scoped GlideAggregate class extends the functionality of GlideRecord and supports various aggregation functions such as AVG, COUNT, GROUP_CONCAT, MAX, MIN, STDDEV, and SUM. This capability is particularly useful for generating custom reports and performing complex calculations.
New Method: setIntervalYearIncluded(Boolean b)
- Purpose: Sets whether to group results by year for day-of-week trends using the
addTrend('fieldName', 'dayofweek')
method. - Dependency: Requires
addTrend('<fieldName>', 'dayofweek')
for day-of-week trends.
Example -
var incidentGroup = new GlideAggregate('incident');
incidentGroup.addEncodedQuery("sys_created_onRELATIVEGT@month@ago@6");
incidentGroup.addTrend('sys_created_on', 'dayofweek');
incidentGroup.addAggregate('COUNT');
incidentGroup.setIntervalYearIncluded(false);
incidentGroup.query();
while (incidentGroup.next()) {
gs.info(incidentGroup.getValue('timeref') + ': ' + incidentGroup.getAggregate('COUNT'));
}
Output :
Sunday: 1
Monday: 15
Tuesday: 1
Wednesday: 7
Thursday: 16
Saturday: 1
2. GlideRecord - Scoped
Overview: GlideRecord API remains pivotal for server-side database interactions in ServiceNow. It retrieves records from a single table, allowing operations such as querying, filtering, limiting, and sorting.
New Method: updateWithReferences(Object reason)
- Purpose: Updates a record and simultaneously inserts or updates related records based on provided information.
Example:
var inc = new GlideRecord('incident');
inc.get(inc_sys_id);
inc.caller_id.first_name = 'John';
inc.caller_id.last_name = 'Doe';
inc.updateWithReferences();
3. ProcessMiningForExternalData - Scoped, Global
Overview: ProcessMiningForExternalData API facilitates processing external audit records, crucial for integrating data from systems like SAP, SmartRecruiters, or JIRA.
New Method: scheduleCaseGeneration(String externalDataSysId)
- Purpose: Marks a record in the External dataset table for processing, enabling automation of audit data processing.
Example:
var result = ProcessMiningForExternalData.scheduleCaseGeneration("o83ehu2yv918ehbu23eg928dg7jbcf52");
gs.info(result);
Output:
{
"status": "success",
"message": "External dataset is scheduled for processing"
}
4. ProductInstance API - Scoped, Global
Overview: ProductInstance API in the sn_cmdb namespace generates unique identifiers (PID) for product instances and manages related configuration data.
New Method: generatePID(String className, String modelCategorySysId, Object jsonKeyValues)
- Purpose: Generates a hashed PID for a product instance based on specified parameters.
Example:
var output = sn_cmdb.ProductInstance.generatePID('sn_ent_medical_asset', '4b8aa89a77710110dd5fca22fe5a9984', { "serial_number" : "SN1001"});
gs.info(JSON.stringify(output,null,'\t'));
5. XMLDocument2 - Scoped, Global
Overview: XMLDocument2 API provides utilities for parsing and manipulating XML data within JavaScript, supporting scoped and global applications.
New Method: setEnableCDATAReporting(Boolean enable)
- Purpose: Configures whether nodes are treated as CDATA or regular text after XML parsing.
Example:
var xmlString = "<test>...</test>";
var xmlDoc = new XMLDocument2();
xmlDoc.setEnableCDATAReporting(true); // Enable CDATA reporting
xmlDoc.parseXML(xmlString);
var content = xmlDoc.getFirstNode('/test/one/two');
gs.info(content.getFirstChild().getTextContent()); // prints "another"
6. XMLNode - Scoped, Global
Overview: XMLNode API extracts and queries values from XML nodes derived from XMLDocument2 objects.
New Method: isCDATANode()
- Purpose: Indicates if a node preserves CDATA as a separate entity.
Example:
var xmlString = "<test>...</test>";
var xmlDoc = new XMLDocument2();
xmlDoc.setEnableCDATAReporting(true); // Enables CDATA reporting
xmlDoc.parseXML(xmlString);
var content = xmlDoc.getFirstNode('/test/one/four');
gs.info(content.getFirstChild().isCDATANode()); // true
Conclusion
These new additions and enhancements empower ServiceNow developers and administrators with advanced capabilities for data processing, reporting, and system integration. Stay updated with the latest tools and methods to leverage ServiceNow effectively in your organization.
For more detailed information, refer to the ServiceNow documentation or contact our support team.
#ServiceNow #WashingtonDC #ProductUpdates #APIs #ScopedClasses #GlideAggregate #GlideRecord #XMLDocument2 #ProcessMiningForExternalData #ProductInstance
- 626 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2024 11:54 PM
Thanks for sharing @Vaishnavi Lathk this was vey useful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2024 01:53 AM
Thanks for your feedback!!!!!!