Welcome Login
Blog Photos Links

RSS Feed

Simple Variable Summary

January 13, 2016, 2:52 pm - James Farrer

 I ran into a problem today where I needed a summary of requested item variables to send out in an email notification. I didn't see a good script for doing it but found a number that were close. Here's my version that does some checking to only show variables that would normally have content suitable to a summary. I'm sure there's room for additional improvement but for the time being this did the trick:

function printVariableSummary(){

   // Variable types that shouldn't be shown

   hidden_types = {

      12:true,

      20:true,

      24:true,

      19:true,

      11:true,

      14:true,

      17:true,

      25:true,

      15:true

   };

   template.print('<strong>Item Options</strong><br/>');

   var set = new GlideappVariablePoolQuestionSet();

   set.setRequestID(current.sys_id);

   set.load();

   var vs = set.getFlatQuestions();

   // Go through all the variables

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

      // Skip variables without a label or that are a type that should be skipped

      if(vs.get(i).getLabel() != '' && !hidden_types[vs.get(i).getType()]) {

          template.space(4);

          template.print('     <strong>' +  vs.get(i).getLabel() + ":</strong> " + vs.get(i).getDisplayValue() + "<br />");

      }

   }

}

printVariableSummary();

Post a Comment

Name:

To reduce spam comments, please answer the following question:
What is two plus one?

What's New

There are currently no new items, please check back later.

Archives
2017 (1)
  January (1)
2016 (4)
  December (1)
  November (1)
  May (1)
  January (1)
2015 (1)
  December (1)
2014 (2)
  August (1)
  February (1)
2013 (4)
  October (1)
  July (1)
  June (1)
  April (1)
2012 (11)
  December (2)
  October (3)
  September (1)
  May (1)
  April (1)
  February (2)
  January (1)
2011 (14)
  December (1)
  November (1)
  September (2)
  July (2)
  June (1)
  May (1)
  April (2)
  March (3)
  January (1)
2009 (2)
  October (1)
  June (1)
2008 (1)
  September (1)