SmartData (Script Include + AJAX) — secure GA/GR auto helper #2043
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.