- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 02:29 AM
I want to get catalog item variables from ritm using GlideRecord or rest api
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 05:04 AM
Hi @rvranjan_99
in a GlideRecord for the sc_req_item table you can access all variables via the variables variable.
For example, if you have a variable u_size you can get the value via:
var grRITM = new GlideRecord('sc_req_item');
grRITM.get('<SYS_ID>');
gs.info(grRITM.variables.u_size);
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 06:27 AM
Hello @rvranjan_99 ,
Yes yon use
// Create a new GlideRecord object for the 'sc_req_item' table
var grRITM = new GlideRecord('sc_req_item');
// Retrieve a specific sc_req_item record by its sys_id
grRITM.get('<ANOTHER_SYS_ID>');
// Access and log the value of the 'requested_for' variable
gs.info(grRITM.variables.requested_for);
GlideRecord Initialization:
- var grRITM = new GlideRecord('sc_req_item');
- The GlideRecord object is initialized for the 'sc_req_item' table.
- var grRITM = new GlideRecord('sc_req_item');
Record Retrieval:
- grRITM.get('<ANOTHER_SYS_ID>');
- It retrieves a specific sc_req_item record based on its sys_id. Replace <ANOTHER_SYS_ID> with the actual sys_id of the desired sc_req_item record.
- grRITM.get('<ANOTHER_SYS_ID>');
Variable Access:
- gs.info(grRITM.variables.requested_for);
- The code accesses the 'variables' field of the GlideRecord (grRITM.variables).
- The specific variable 'requested_for' is accessed, and its value is logged using gs.info().
- gs.info(grRITM.variables.requested_for);
Ensure to replace <ANOTHER_SYS_ID> with the sys_id of an existing sc_req_item record in your instance. This example demonstrates how to work with a different variable in the context of the sc_req_item table.
Additionally, if you have the SN Utils extension installed, you can use the GlideRecord Tab within the extension. It provides a sample script with all variable values. Execute the script in the background script, and you'll see all variable values in the message log.
This script includes a check for record validity and variable existence to ensure robustness. The note about the SN Utils extension provides an alternative approach for exploring variable values conveniently.
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
AnikeT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 07:54 AM
Hi @rvranjan_99
Please refer below code if you want all the variables of the catalog.
Thanks and Regards,
Saurabh Gupta