- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 08:57 AM
Hi,
I have a requirement to get values present in standard change template. From a template I would like to get the value of owner group but unable to fetch them.
Currently I'm using a script to get value present in array place 5 but the drawback is in few templates, the owner group value is placed else where, hence returning the wrong value. I would like to get the value of owner group field and the script I use is
var temp = new GlideRecord('std_change_record_producer');
temp.addEncodedQuery('active=true');
temp.addEncodedQuery('u_numberIN123');
temp.query();
while (temp.next()) {
var unqval = temp.getUniqueValue();
var rec = new GlideRecord('std_change_record_producer');
rec.get(unqval);
var util = new StdChangeUtilsSNC();
var opr = util._parseEncodedQuery(rec.template.template);
var assgrp = opr.vals[4]; //assgrp holds the 5th place value from the array.
Is there anyway that I could get the value of owner group irrespective of where it is placed.
Thanks for the response in advance.
Regards,
Manjushree
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:58 AM
Thanks for the response. The below script helped me to get a particular value.
var temp = new GlideRecord('std_change_record_producer');
temp.addEncodedQuery('active=true');
temp.addEncodedQuery('u_numberIN123');
temp.query();
while (temp.next()) {
var unqval = temp.getUniqueValue();
var rec = new GlideRecord('std_change_record_producer');
rec.get(unqval);
var assgrp = rec.template.template;
gs.log(assgrp);
assgrp = assgrp.split("assignment_group=")[1];
var group = assgrp.substring(0,32);
gs.log(group);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:15 AM
Hi,
Unsure, about the field name but can you try indexOf() instead of array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:18 AM
Hi,
Could you please provide the synatx on how to use indexof() here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:22 AM
Something as below.
var assgrp = opr.vals[4];
can be
var assgrp = opr.vals;
if(assgrp.indexOf('assignment_group')>-1) //here assignment_group is suppose field name
{
//do this
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 09:24 AM
opr.vals is only returning the field values and not field names.