How to access Standard Change template change field values

Manju Shree
Tera Expert

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.

ManjuShree_0-1667231552911.png

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

 

1 ACCEPTED SOLUTION

Manju Shree
Tera Expert

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);
}

View solution in original post

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi,

Unsure, about the field name but can you try indexOf() instead of array.

 

Hi,

 

Could you please provide the synatx on how to use indexof() here

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

}

opr.vals is only returning the field values and not field names.