Fix for GlideappVariablePoolQuestionSet is not allowed in scoped applications

Kathy3
Giga Contributor

Hi,

I am a total noob at JS, and I am working with code out of the article below to copy variables from RITM forms to the description field on the REQ form.

https://community.servicenow.com/community?id=community_question&sys_id=fa6fb6a9db58dbc01dcaf3231f961966&view_source=searchResult

I would like to know what my options are to alter the particular line so that it will work in our instance. We are on Kingston. I included the rest of the code below. TIA!

 

var gr= new GlideRecord("sc_req_item");

 

  gr.addQuery('request',current.sys_id);

 

  gr.query();

 

  var varArr='';

 

  while(gr.next()){

 

  var set = new GlideappVariablePoolQuestionSet();

 

  set.setRequestID(gr.sys_id);

 

  set.load();

 

  var vs = set.getFlatQuestions();

 

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

 

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

 

  varArr+=vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue()+'\n';

 

  }

 

  }

 

  }

 

  current.description=varArr;

 

2 REPLIES 2

Jace Benson
Mega Sage

Please use the editor so your code looks like this
find_real_file.png Also regarding your question, I'd write your own;

https://blog.jace.pro/post/2018-02-15-print-out-variables/

Kathy3
Giga Contributor

Thanks, I will try that out. I did notice when I was creating the rule, that it was on the ITSM spoke and not Global. O think that is where the conflict is.