
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 01:34 AM
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 04:42 AM
This is the complete code.
var authorityrole = [];
var gr = new GlideRecord('customer_contact');
gr.addQuery('sys_id', current.contact);
gr.query();
while (gr.next()) {
var pa = gs.getProperty('sn_customerservice.PASA');
var pasa = pa.split(',');
gs.info('PASA: ' + pasa);
if (current.u_authority_role.changes()) {
var auth_role = current.u_authority_role.toString();
gs.info('AuthRole: ' + auth_role);
var authrole = auth_role.split(',');
var found = false;
for (var i = 0; i < pasa.length; i++) {
if (authrole.indexOf(pasa[i]) !== -1) {
found = true;
authorityrole.push(pasa[i]);
}
}
if (found) {
gs.info('insideIF');
gr.u_comments = "Responsibility for account " + current.company.name + " and contact " + current.contact.name + " has changed to: " + authorityrole.toString();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 01:42 AM
Hi,
What do you get for this info message?
gs.info('PASA:' + pasa);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 02:59 AM
comma separated sys_ids
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:08 AM - edited 05-21-2024 03:11 AM
when you split it by the , is becomes an array, pasa is an array now.
When you compare it with Index of you need to use either pasa[0] OR pasa[1] and so on or put it in a loop and use the counter pasa[i]
Try this
var authorityrole = [];
var gr = new GlideRecord('customer_contact');
gr.addQuery('sys_id', current.contact);
gr.query();
while (gr.next()) {
var pa = gs.getProperty('sn_customerservice.PASA');
var pasa = pa.split(',');
gs.info('PASA:' + pasa);
if (current.u_authority_role.changes()) {
var auth_role = current.u_authority_role.toString();
gs.info('AuthRole:' + auth_role);
var authrole = auth_role.split(',');
for (var c = 0;c< pasa.length;c++)
{
if (authrole.toString().indexOf(pasa[c]) == -1) {
gs.info('insideIF');
for (var i = 0; i < authrole.length; i++) {
gs.info('Into Res:');
// gs.info('Got PASA:');
authorityrole.push(authrole[i]);
}
}
gr.u_comments = "" + "Responsiblity for account " + current.company.name + " and contact " + current.contact.name + " has changed to:" + authorityrole.toString();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:21 AM
auth_role -->Has comma separated sys_ids
pasa -->Has comma Separated sys_ids
My requirement is to find any sys_id of pasa is in auth_role. If no ids found then goto For loop ?and add comments else do not go. Will this work?