Hi

radha050903
Tera Contributor

is there anyone who knows about GlideAppVariablePool API?

1 ACCEPTED SOLUTION

DiveshTyagi
Mega Guru

Hi @radha050903 ,

 

 

GlideAppVariablePoolQuestionSet is a ServiceNow server-side API used to retrieve and process Service Catalog variables (questions and answers) that are stored in the platform’s variable pool.

It is commonly used when working with records generated from the Service Catalog, including:

  • sc_req_item (Request Item / RITM)

  • sc_task

  • sc_request

  • Records created via Record Producers


What is a Variable Pool?

In ServiceNow, catalog variables are not stored directly on catalog-related tables such as sc_req_item or sc_task.

Instead, variable data is stored in dedicated tables that collectively form the variable pool, primarily:

  • sc_item_option

  • sc_item_option_mtom

These tables store the definition, value, and relationship of variables and link them to the appropriate catalog records.


Role of GlideAppVariablePoolQuestionSet

GlideAppVariablePoolQuestionSet provides a simplified and structured API to access catalog variables without querying the underlying variable pool tables directly.

Using this API, a developer can:

  • Load all catalog variables associated with a specific record

  • Iterate through the list of questions

  • Retrieve important variable attributes, including:

    • Variable name

    • Label

    • Actual value

    • Display value

This approach improves readability, maintainability, and performance compared to manually querying catalog variable tables.

 

 

Example :

var emptyVariables = [];
var readonlyVariables = [];
var keys = [];
var ritmSysId = '9a0239c6c3e762105ea3bb45990131f7';

var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();

var vs = set.getFlatQuestions();

for (var i = 0; i < vs.size(); i++) {

    var question = vs.get(i);

    var displayValue = question.getDisplayValue().toString();
    var label = question.getLabel().toString();
    var name = question.getName().toString();
    gs.print(
        'Variable Name: ' + name +
        ' | Label: ' + label +
        ' | Value: ' + displayValue
    );
    if (!displayValue) {
        emptyVariables.push(name);
    }
    if (question.isReadOnly()) {
        readonlyVariables.push(name);
    }
    keys.push(name);
}
gs.print('Empty Variables: ' + emptyVariables.join(', '));
gs.print('Readonly Variables: ' + readonlyVariables.join(', '));
gs.print('All Variable Names: ' + keys.join(', '));

 

 

 

---------------------------------------------------------------------------------------------------------------------------------

If this helps you then mark it as helpful and accept as solution.

View solution in original post

3 REPLIES 3

GlideFather
Tera Patron

Hi @radha050903,

 

the SN Docs found only this:

 

GlideappVariablePoolQuestionSet

Packages.com.glideapp.servicecatalog.variables.VariablePoolQuestionSet

source: Packages Call Removal tool

 

Unsolicited advice: Instead of asking if there's anyone who knows about something, just go and ask directly what you want to know, the probability of getting it answered is higher ;))

_____
No AI was used in the writing of this post. Pure #GlideFather only

This is impressively unhelpful. A class name, zero explanation, no answer to the actual question, and a side of unsolicited “how to ask questions” advice.
 
-Copilot

DiveshTyagi
Mega Guru

Hi @radha050903 ,

 

 

GlideAppVariablePoolQuestionSet is a ServiceNow server-side API used to retrieve and process Service Catalog variables (questions and answers) that are stored in the platform’s variable pool.

It is commonly used when working with records generated from the Service Catalog, including:

  • sc_req_item (Request Item / RITM)

  • sc_task

  • sc_request

  • Records created via Record Producers


What is a Variable Pool?

In ServiceNow, catalog variables are not stored directly on catalog-related tables such as sc_req_item or sc_task.

Instead, variable data is stored in dedicated tables that collectively form the variable pool, primarily:

  • sc_item_option

  • sc_item_option_mtom

These tables store the definition, value, and relationship of variables and link them to the appropriate catalog records.


Role of GlideAppVariablePoolQuestionSet

GlideAppVariablePoolQuestionSet provides a simplified and structured API to access catalog variables without querying the underlying variable pool tables directly.

Using this API, a developer can:

  • Load all catalog variables associated with a specific record

  • Iterate through the list of questions

  • Retrieve important variable attributes, including:

    • Variable name

    • Label

    • Actual value

    • Display value

This approach improves readability, maintainability, and performance compared to manually querying catalog variable tables.

 

 

Example :

var emptyVariables = [];
var readonlyVariables = [];
var keys = [];
var ritmSysId = '9a0239c6c3e762105ea3bb45990131f7';

var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);
set.load();

var vs = set.getFlatQuestions();

for (var i = 0; i < vs.size(); i++) {

    var question = vs.get(i);

    var displayValue = question.getDisplayValue().toString();
    var label = question.getLabel().toString();
    var name = question.getName().toString();
    gs.print(
        'Variable Name: ' + name +
        ' | Label: ' + label +
        ' | Value: ' + displayValue
    );
    if (!displayValue) {
        emptyVariables.push(name);
    }
    if (question.isReadOnly()) {
        readonlyVariables.push(name);
    }
    keys.push(name);
}
gs.print('Empty Variables: ' + emptyVariables.join(', '));
gs.print('Readonly Variables: ' + readonlyVariables.join(', '));
gs.print('All Variable Names: ' + keys.join(', '));

 

 

 

---------------------------------------------------------------------------------------------------------------------------------

If this helps you then mark it as helpful and accept as solution.