Skip to content

Conversation

@abhix2112
Copy link
Contributor

What this adds
A tiny utility that auto-selects GlideAggregate (for count/distinct/stats) vs GlideRecord (for one/list) and exposes describe(table) and preview(table, query). Includes a client-callable GlideAjax wrapper that sanitizes the encoded query via GlideStringUtil.escapeQueryTermSeparator().

Why it’s useful

One API for common reads; engine chosen automatically.

Dev-friendly helpers: schema describe + quick preview.

AJAX-ready for UI scripts / UI actions.

Secure-by-default handling of sysparm_query.

How to test

Background Script:

``
var sd = new SmartData();
gs.info('Count: ' + sd.count('incident', 'active=true'));
gs.info(JSON.stringify(sd.stats('incident', {fn:'AVG', field:'time_worked'}, ['assignment_group'], 'active=true')));
gs.info(JSON.stringify(sd.one('incident', 'active=true', ['number','priority'], '-sys_created_on')));
gs.info(JSON.stringify(sd.describe('problem')));

``

Security note
SmartDataAjax uses GlideStringUtil.escapeQueryTermSeparator() to harden sysparm_query.

@am-shakeel am-shakeel self-assigned this Oct 12, 2025
Copy link
Contributor

@am-shakeel am-shakeel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

@am-shakeel am-shakeel merged commit dedf344 into ServiceNowDevProgram:main Oct 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants