- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:09 PM
why we are using encoded query and @javascript syntax
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:34 PM
The addEncodedQuery function allows you to add a query to a GlideRecord object using an encoded query string. An encoded query string is a string that represents a query in a URL-friendly format. This format is typically used in URLs to represent complex queries with special characters or operators.
The @javascript: syntax is a way to execute JavaScript functions within the encoded query string. This is useful when you need to perform dynamic calculations or comparisons as part of your query.
In your specific example:
The sys_updated_on field is being compared against a dynamic range, from the beginning of today (gs.beginningOfToday()) to the end of today (gs.endOfToday()). This ensures that you're querying for records where the sys_updated_on field falls within the current day.
Using @javascript: allows you to execute ServiceNow's gs (GlideSystem) functions directly within the encoded query string, enabling dynamic date calculations.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:48 PM
Hi @Rajkumar Bommal ,
Encoded query syntax is used to build the complex query to filter the data. This will help us to reduce the mistake happens while and / or operations in the query using addQuery() or addOrCondition() syntax.
However gs is the global object in ServiceNow and we use beginningOfToday() & endOfToday() functions.
beginningOfToday() :
endOfToday() :
Retrieves the date and time for the end of today in GMT & return value is string in GMT in the format yyyy-mm-dd hh:mm:ss.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me.
Thank you!
Abhishek Dalvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:34 PM
The addEncodedQuery function allows you to add a query to a GlideRecord object using an encoded query string. An encoded query string is a string that represents a query in a URL-friendly format. This format is typically used in URLs to represent complex queries with special characters or operators.
The @javascript: syntax is a way to execute JavaScript functions within the encoded query string. This is useful when you need to perform dynamic calculations or comparisons as part of your query.
In your specific example:
The sys_updated_on field is being compared against a dynamic range, from the beginning of today (gs.beginningOfToday()) to the end of today (gs.endOfToday()). This ensures that you're querying for records where the sys_updated_on field falls within the current day.
Using @javascript: allows you to execute ServiceNow's gs (GlideSystem) functions directly within the encoded query string, enabling dynamic date calculations.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2024 09:48 PM
Hi @Rajkumar Bommal ,
Encoded query syntax is used to build the complex query to filter the data. This will help us to reduce the mistake happens while and / or operations in the query using addQuery() or addOrCondition() syntax.
However gs is the global object in ServiceNow and we use beginningOfToday() & endOfToday() functions.
beginningOfToday() :
endOfToday() :
Retrieves the date and time for the end of today in GMT & return value is string in GMT in the format yyyy-mm-dd hh:mm:ss.
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me.
Thank you!
Abhishek Dalvi