- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 04:36 AM
Requirement - Populate Short description based in choice selected for a variable.
I am configuring a workflow which can be utilize by many SR, for that I have created a table from where I am fetching the required data and setting it for task details.
Few SR's task have short description based on selected request type. Which can be achieved by
task.short_description = "xyxyxyxyxyxy" + current.variables.req_type;
Now for few SR, dependent variable name is other than req_type;
So I found a solution that I will pass the variable name from 'abcabc' table and based on this variable name, I will set Short description.
task.short_description = "xyxyxyxyxyxy" + current.variables.Dynamic_Variable_from_abcabc_table;
Below script is not working to setting the task short description.
Let me know how this will work or any workaround for it.
var config = new GlideRecord('abcabc');
config.addQuery('u_req','TEST SR');
config.query();
while(config.next()){
task.short_description = "xyxyxyxyxyxy" + current.variables.config.u_variable_name;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 10:51 PM
Hi
I think I got yout requirement. What I prepared for you, is a small script, which shows, how you could to dynamically, about what you want to do:
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', 'RITM0010032');
gr.query();
if (gr.next()) {
gs.info('got it: ' + gr.number);
gs.info(gr.variables.getElements());
gs.info(gr.variables.what_county.getValue());
var current = gr;
var useThisVariableName = 'what_country';
var theValueToSet = '';
var variables = current.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
if (question.name == useThisVariableName) {
theValueToSet = question.getValue();
}
// gs.addInfoMessage(question.name + " / " + question.getLabel() + ":" + question.getValue());
}
gs.info('The value of the variable called ' + useThisVariableName + ' is ' + theValueToSet);
}
Take this as a starting point to get variable values for having the NAME of the variable to use, in a different variable.
Let me know if that answers your question and mark my answer as correct helpful.
Thanks & BR
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 04:40 AM
Hi
I do not get your requirement details. May you give a bit more details about your requirement?
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 04:53 AM
I am configuring a workflow which can be utilize by many SR, for that I have created a table from where I am fetching the required data and setting it for task details.
Few SR's task have short description based on selected request type. Which can be achieved by
task.short_description = "xyxyxyxyxyxy" + current.variables.req_type;
Now for few SR, dependent variable name is other than req_type;
So I found a solution that I will pass the variable name from 'abcabc' table and based on this variable name, I will set Short description.
task.short_description = "xyxyxyxyxyxy" + current.variables.Dynamic_Variable_from_abcabc_table;
I hope you will have some clarification on the requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 10:51 PM
Hi
I think I got yout requirement. What I prepared for you, is a small script, which shows, how you could to dynamically, about what you want to do:
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', 'RITM0010032');
gr.query();
if (gr.next()) {
gs.info('got it: ' + gr.number);
gs.info(gr.variables.getElements());
gs.info(gr.variables.what_county.getValue());
var current = gr;
var useThisVariableName = 'what_country';
var theValueToSet = '';
var variables = current.variables.getElements();
for (var i=0;i<variables.length;i++) {
var question = variables[i].getQuestion();
if (question.name == useThisVariableName) {
theValueToSet = question.getValue();
}
// gs.addInfoMessage(question.name + " / " + question.getLabel() + ":" + question.getValue());
}
gs.info('The value of the variable called ' + useThisVariableName + ' is ' + theValueToSet);
}
Take this as a starting point to get variable values for having the NAME of the variable to use, in a different variable.
Let me know if that answers your question and mark my answer as correct helpful.
Thanks & BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2020 09:58 AM
Thanks Dirk. I will check this and get back.