Alternative for GlideappVariablePoolQuestionSet() in scoped app

Nagashree5
Tera Contributor

Hi All.

 

I have created a scoped application and created a table which extends the task which is called SDCase. On this I have built few Record producers and created a formatter as well to display the variable section on the SDCase once it is created.

I have created a new record producer, where we select the SDcase(which only shows closed ones) on the form level, on selction of the SDcase it should automatically fill the form with the closed SDCase variable values.Now My requirement is how to fetch the variable values from a closed SDRequest and populate them on the form level variables. For this I'm using the below script include to fetch the values.

I'm able to fetch successfully in global application but I'm unable to fetch in my scoped application as Im using GlideappVariablePoolQuestionSet(). 

Script Include:

var Copy_exixsting_ritm = Class.create();
Copy_exixsting_ritm.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRITMDetails: function() {
var ritm_number = this.getParameter('sysparm_ritm');
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritm_number);
set.load();
var vs = set.getFlatQuestions();
var object = {};
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getLabel() != '' && vs.get(i).getValue() != '') {
object[vs.get(i).getName()] = vs.get(i).getValue();
object['dv_' + vs.get(i).getName()] = vs.get(i).getDisplayValue();
}
}
var data = JSON.stringify(object);
return data;
},
type: 'Copy_exixsting_ritm'
});

 

Can anyone please suggest a alternative for this.

 

Thank you in Advance.

1 REPLY 1

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Nagashree5 

Try this.

var ritm_number = this.getParameter('sysparm_ritm');
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('number', ritm);
ritm.query();
if (ritm.next()) {
    var v;
    for (var i in ritm.variables) {
        v = ritm.variables[i];
        if (v.getGlideObject().getQuestion().getLabel() != '' && v.getDisplayValue() != '') {
            //do something
        }
    }
}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP