- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-14-2017 06:12 AM
Having worked with Record Producers the last few weeks I built this little solution I hope may help some out there.
My issue was that I needed a lot of Record Producers that contained very similar information, but I was not interested in writing anything manually unless absolutely forced to. This meant all additions to the Record Producers should be their specific unique data and not copy paste a bunch into each script (if for nothing else than if something happened, I would have to manually change each one). Because of this I decided to use variable sets and script includes (as one does).
When a Record Producer creates for example a change, as soon as the workflow starts for the change, all instructions in a variable set will stop and the Record Producer variables will not be directly reachable through the workflow.
What is accessible is the table question_answer_list.do that stores all variables and their answers.
Currently my workflow calls a script include that in turn checks all variables, their answers and provides these to the change description field (I currently don't need any additional fields filled out as this is handled by the variable set).
Workflow script:
var myVariable = new getVariablesScriptInclude();
myVariable.getValuesFromVariables(current);
Script include:
var getVariablesScriptInclude = Class.create();
getVariablesScriptInclude.prototype = {
inititalize : function() {
},
getValuesFromVariables: function (current){
//Set variables for change and two empty strings
var myID = current.sys_id;
var string3 = '';
var string4 = '';
//Query the table question_answer_list.do for all variables related to the Change where there is a value and a question
var producerVars = new GlideRecord('question_answer');
producerVars.addQuery('table_sys_id', myID);
producerVars.addNotNullQuery('value');
producerVars.addNotNullQuery('question');
//Remove container variables
producerVars.addQuery('question.type', '!=', 19); // Container Start
producerVars.addQuery('question.type', '!=', 20); // Container End
producerVars.addQuery('question.type', '!=', 24); // Container Split
//Order answers according to order field
producerVars.orderBy('question.order');
producerVars.query();
while(producerVars.next()){
//Get information from the variable, such as question asked and answer as well as variable set it contains in
var type = producerVars.question.type;
var label = producerVars.question.question_text;
var name = producerVars.question.name;
var varSet = producerVars.question.variable_set;
var question = current.variables[producerVars.question.name.toString()];
var value = question.getGlideObject().getQuestion().getDisplayValue();
//If it's a specific variable set, get the information in the description field and add it to a variable with some returns
if(varSet == 'sys_id of variable set' && name == 'variable name of description field'){
{
string4 = '\n\n\nRequested information for this change:\n';
}
}
//If a specific variable set, do not get those variables (these are set with name to name in my Record Producer)
if(varSet != 'sys_id of variable set'){
//Depending on what kind of variable, handle the answer differently, as some should be spaced differently
if(type == '2'){
string3 += '\n' +label +":\n" +value +"\n\n";
}
else
string3 += label +": " +value +"\n";
}
}
if(string3 != ''){
current.description += string4 +string3;
}
},
type: 'getVariablesScriptInclude'
};
With this, all my Record Producers fetch the different variables provided manually and add them to the description field of the change. This can of course be modified any which way is desired, but may provide you with a start in automizing variable management.
- 5,423 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How i can get it with mobile recorders or what i need to do.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I'll look into it, if you haven't found the solution already.
It should work the same, if your record producer is set to be available on mobile.
Regards, Anton