Skip to content

Conversation

@raghavs046
Copy link
Contributor

PR Description:

Pull Request Checklist

Overview

  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories:
    • Core ServiceNow APIs/
    • Server-Side Components/
    • Client-Side Components/
    • Modern Development/
    • Integration/
    • Specialized Areas/
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes:
    • Description of the code snippet functionality
    • Usage instructions or examples
    • Any prerequisites or dependencies
    • (Optional) Screenshots or diagrams if helpful

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

@WillemZeiler WillemZeiler self-assigned this Oct 7, 2025
@@ -0,0 +1,13 @@
var incRec = new GlideRecord('incident');
incRec.addEncodedQuery('assignment_group=287ee6fea9fe198100ada7950d0b1b73^active=true'); // encoded Query to get incients assigned to particular group
Copy link
Contributor

Choose a reason for hiding this comment

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

You are using a sys_id, can you in the comment add what it refers to?

var incRec = new GlideRecord('incident');
incRec.addEncodedQuery('assignment_group=287ee6fea9fe198100ada7950d0b1b73^active=true'); // encoded Query to get incients assigned to particular group
incRec.query();
var eQry = incRec.getEncodedQuery();
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment to show that this returns the encodedQuery

var eQry = incRec.getEncodedQuery();

while(incRec.next()){
var iTask = new GlideRecord('incident_task');
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not executing this query. Additionally, why are you looking at incident_task here?

Copy link
Contributor Author

@raghavs046 raghavs046 Oct 7, 2025

Choose a reason for hiding this comment

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

@WillemZeiler I am using eQry to apply the query below. The requirement was to have an extra record for reporting purpose later.


1.In any GlideRecord query retrieve query using getEncodedQuery()

2.Apply this encoded query to create/update records (you can apply this query to other tables if query is appropriate).
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have examples where you used this and why? That way it will add value in addition to the standard documentation: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideRecord/concept/c_GlideRecordAPI.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WillemZeiler This was a client requirement, where for a particular group they wanted a task generated to log some internal extra work they were doing during some of their internal transition.

This was done through a scheduled job (daily) for the required period and then the scheduled job was deactivated.

@WillemZeiler
Copy link
Contributor

Thank you for your submission. I have added comments in your code. Please note that, in order to merge this PR it needs to have clear additional benefits in reference to the standard documentation and example on getEncodedQuery here: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/GlideRecord/concept/c_GlideRecordAPI.html

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