- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2021 09:48 PM
Hi Team,
how to populate the current catalog variable values to RITM description
below variables and variable set fields.
i have 3 variables and one variable set (variable set have 2 fields).
variables
1. account
2. year
3.quarter
variable set
4. select location (location and balance)
how write workflow run script
Regards,
Pushpa
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2021 12:21 AM
Hi,
account variable should work fine using this
current.variables.account.getDisplayValue();
OR you can query the account table with the sys_id and print the name
then for stockroom showing country do this
var desc = current.variables.description;
if (current.cat_item.name == "Laptop Projection Request") {
desc += '\nAccount: ' + current.variables.account.getDisplayValue();
desc += '\nYear: ' + current.variables.year;
desc += '\nQuarter: ' + current.variables.quarter;
var parser = JSON.parse(current.variables.add_stockroom_location_and_projection);
var arr = [];
for(var i=0;i<parser.length;i++){
var gr = new GlideRecord("alm_stockroom"); // give here the table name
gr.addQuery("sys_id", parser[i].stockroom);
gr.query();
if (gr.next()) {
var str = '';
str = str + "Stockroom: " + gr.location.country + " | " + gr.name + " Projection: " + parser[i].projection;
arr.push(str);
}
}
desc += '\nAdd Stockroom Location and Projection: ' + arr.join('\n');
current.description = desc;
current.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2021 11:43 PM
Hi Ankur,
now account getting undefine
Yes fine stockroom related information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2021 11:48 PM
Hi,
but the line of code is the same
current.variables.account.getDisplayValue()
Did you check the account variable has some value or not
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2021 11:49 PM
Hi Pushpa,
Glad to know that the stockroom related information is working fine.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2021 11:55 PM
Hi Ankur,
if we remove the getDisplayValue(). getting sys id of account.
if we use getDisplayValue() then getting undefine.
country not getting in the stock room.
output:
test
Account: c25f8ab4dbdf1f40d5bd5478dc961991
Year: 2021
Quarter: Q2
Add Stockroom Location and Projection: Stockroom: Aliso Viejo Projection: 12
Stockroom: Chennai Projection: 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2021 12:01 AM
Hi,
what is the variable type for account?
can you share variable configuration image for stockroom within MRVS?
which field in alm_stockroom holds the Country | Location data?
use that in the script then
var desc = current.variables.description;
if (current.cat_item.name == "Laptop Projection Request") {
desc += '\nAccount: ' + current.variables.account.getDisplayValue();
desc += '\nYear: ' + current.variables.year;
desc += '\nQuarter: ' + current.variables.quarter;
var parser = JSON.parse(current.variables.add_stockroom_location_and_projection);
var arr = [];
for(var i=0;i<parser.length;i++){
var gr = new GlideRecord("alm_stockroom"); // give here the table name
gr.addQuery("sys_id", parser[i].stockroom);
gr.query();
if (gr.next()) {
var str = '';
str = str + "Stockroom: " + gr.yourField + " Projection: " + parser[i].projection;
arr.push(str);
}
}
desc += '\nAdd Stockroom Location and Projection: ' + arr.join('\n');
current.description = desc;
current.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader