Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

flow designer script the assignment group based on a catalog variable chosen

Community Alums
Not applicable

for 'Create Catalog Task' action in my flow, I have scripted the Assignment Group as one that has a name that starts with 'CLD - Saas' and contains the name of the product variable: 

var ag = fd_data.trigger.current.assignment_group;
var product = fd_data.trigger.current.variables.product;

var group = new GlideRecord('sys_user_group'); 
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product); 
group.query(); 
if (group.next()) { 
    ag = group;
}
return ag;

but when I try to activate the flow it gives me an error about not being able to use 'current'. 

What am I doing wrong? 

13 REPLIES 13

Voona Rohila
Mega Patron
Mega Patron

Hi Annie

Try this

var ag = fd_data.trigger.current.assignment_group;
var product = fd_data.trigger.current.variables.product;

var group = new GlideRecord('sys_user_group'); 
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product); 
group.query(); 
if (group.next()) { 
    ag = group.sys_id;
}
return ag;

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

@Annie M 

this should work fine

var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);

var product = rec.variables.product;

var group = new GlideRecord('sys_user_group');
group.addEncodedQuery('nameSTARTSWITHCLD - SaaS^nameLIKE' + product);
group.query();
if (group.next()) {
    ag = group.getUniqueValue();
}

return ag;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

This is slightly better than what I have, as it doesn't give me the error about 'current' when I try to activate the flow. But it doesn't set the assignment group properly on the task. Maybe my logic elsewhere is bad. I did double-check the variable name. 

Hi,

Sure do share the updates.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader