Object Parameters for getFlatQuestions();

mrswann
Kilo Guru

part of my script:

var set = new GlideappVariablePoolQuestionSet();

set.setRequestID(item.sys_id);

set.load();

var vs = set.getFlatQuestions();

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

if (vs.getLabel() != "" && vs.getDisplayValue() != "" && vs.getDisplayValue()!='false' ) {

gs.print("<br/> <b>" + vs.get(i).getLabel() + "</b> = " + vs.get(i).getDisplayValue() + "");

}

I have taken it from a mail script and executing in the background scripts. In both I am getting results where the VALUE of the Variable is coming through as 'false'

How do I stop this?

I have tried all manner or things but would prefer to know what object parameters and legal operations exist? I cannot find this document anywhere.

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

Your code should be this


var set = new GlideappVariablePoolQuestionSet();


                              set.setRequestID(current.sys_id.toString());


                              set.load();


                             


                              var vs = set.getFlatQuestions();


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


                                                              if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue()!='' && vs.get(i).getDisplayValue()!='false') {


                                                                                              test +=' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "<br/>";


                                                              }


                              }


View solution in original post

11 REPLIES 11

No, you do not have any documentation on that. But you can find how it is used in the UI macro "approval_variable_summary"


Also - please refer to this thread: form element names (SC Variables) [Helsinki]



There are two other / better /more robust solutions detailed in there - one which works in both desktop & mobile!


Hey Abhinay,

Thanks for this, it worked.

Can you also please mention what changes we would have to make in case of pulling the variables from the 'sc_task' form.

Regards

karthik73
Mega Guru

Thanks Abhinay for the direction. I am trying to get the variables of the catalog task and the setTaskID is not extracting the variables from the task. I may have to live with the variable pool.


All the variables on sc_req_item will be on sc_task right ? Why do you want the variables of task? What is your use case here?