- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 01:43 AM
Hi,
I am trying to automate the change process to pull a list of approvers from all the affected CIs when the change state is set to 'Approval requested'.
I can get it working when i pull from a single Reference field on a CI but many items have multiple approvers required on them and when i try to pull it from a List field it does nothing at all.
Im using the below script which has been adapted from one i found here.
var answer = [];
var affCIs = new GlideRecord('task_ci');
affCIs.addQuery('task', current.sys_id);
affCIs.query();
while(affCIs.next()){
answer.push(affCIs.ci_item.u_approver__person_); !
}
u_approver__person is the name of the list field im trying to pull from. If you can suggest a field that can serve this function better or correct the script to pull from the List correctly that would be great.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 06:13 AM
Here's an example .. Make sure that the affected CI list is loaded before this activity is being called ...
answer = [];
try
{
var approvers = '';
var ci = new GlideRecord('task_ci');
ci.addQuery('task',current.sys_id);
ci.query();
while (ci.next()) {
if(approvers.length == 0)
{
approvers = approvers + ci.ci_item.u_approver__person_.toString();
}
else
{
approvers = approvers + ',' + ci.ci_item.u_approver__person_.toString();
}
}
var approversArray = (approvers.toString() + ',').split(',');
for(i=0;i<approversArray.length;i++)
{
if(JSUtil.notNil(approversArray[i]))
{
answer.push(approversArray[i]);
}
}
}
catch(err)
{
gs.log('Error While Processing-'+err + '-' +approvers);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 05:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 06:13 AM
Here's an example .. Make sure that the affected CI list is loaded before this activity is being called ...
answer = [];
try
{
var approvers = '';
var ci = new GlideRecord('task_ci');
ci.addQuery('task',current.sys_id);
ci.query();
while (ci.next()) {
if(approvers.length == 0)
{
approvers = approvers + ci.ci_item.u_approver__person_.toString();
}
else
{
approvers = approvers + ',' + ci.ci_item.u_approver__person_.toString();
}
}
var approversArray = (approvers.toString() + ',').split(',');
for(i=0;i<approversArray.length;i++)
{
if(JSUtil.notNil(approversArray[i]))
{
answer.push(approversArray[i]);
}
}
}
catch(err)
{
gs.log('Error While Processing-'+err + '-' +approvers);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2015 02:06 AM
Tried this one also and still no luck im afraid. Is is definately possible to pull from a list field in this way?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2015 02:12 AM
I don't see any errors in the script . One thing you need to make sure. Before this script runs, the affected CI list must be populated .. Trying putting some log statements in the gliderecord and see if the values are being fetched properly ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2015 07:37 AM
Ive managed to get it working. It was an issue with my end
Thank you very much for you patience and your help.