Request Item Variables

rvranjan_99
Tera Contributor

I want to get catalog item variables from ritm using GlideRecord or rest api

2 ACCEPTED SOLUTIONS

Maik Skoddow
Tera Patron
Tera Patron

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

View solution in original post

Aniket Chavan
Tera Sage
Tera Sage

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);

 

  1. GlideRecord Initialization:

    • var grRITM = new GlideRecord('sc_req_item');
      • The GlideRecord object is initialized for the 'sc_req_item' table.
  2. 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.
  3. 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().

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.

 

AniketChavan_1-1705846803584.png

 

AniketChavan_2-1705847258188.png

 

 

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

 

View solution in original post

5 REPLIES 5

Maik Skoddow
Tera Patron
Tera Patron

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

thanks

Aniket Chavan
Tera Sage
Tera Sage

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);

 

  1. GlideRecord Initialization:

    • var grRITM = new GlideRecord('sc_req_item');
      • The GlideRecord object is initialized for the 'sc_req_item' table.
  2. 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.
  3. 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().

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.

 

AniketChavan_1-1705846803584.png

 

AniketChavan_2-1705847258188.png

 

 

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

 

thanks for the explanation!