- 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-24-2020 02:51 AM
Hi
Do you have any update on this?
Did my answer solve your issue?
Just let me know and mark my answer as correct & helpful
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 03:24 AM
Thanks Drik for the solution. It is working and solved my issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 04:42 AM
Hi Raj,
For your statement,
This variable name should be dynamic so that we will change the variable value in abcabc table and task's short description will change accordingly.
You need to have Business rule in place that would update it for the variables already submitted.
- 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 05:53 AM
Thanks for the update Raj. Yes, it helps understand.
So, what is the issue now. If the above script not working?