script to add the assignment group based on user location in flow designer

Srilakshmi7
Tera Contributor

Hello Everyone,

We have a location routing table where we have records based on the locations mapped to the assignment groups

Based on that I have written scripts in flow designer to add the assignment group based on the users location. But it is not working. Can anyone help me with the script.

 

Script:

(function executeRule(current, previous /*null when async*/) {
 
    var locationrouting = new GlideRecord('x_ibmip_tktrouting_location_routing');
    locationrouting.addEncodedQuery('u_active!=false^u_location_route_type=FIELD_SERVICES');
    locationrouting.addQuery('u_location',fd_data.trigger.request_item.location.sys_id);
      locationrouting.query();
    while (locationrouting.next()) {
        var groupName = locationrouting.u_group.name;
        return groupName;
    }
 
})(current, previous);
5 REPLIES 5

Astik Thombare
Tera Sage

Hi @Srilakshmi7 ,

 

Please take a look into below thread -https://www.servicenow.com/community/developer-forum/how-to-populate-assignment-group-based-on-user-...

 

Please mark  Correct if this resolves your issue, and also mark 👍 Helpful if you find my response valuable based on its impact.

 

Regards,

Astik Thombare

Stefan Georgiev
Tera Guru

Hello @Srilakshmi7 ,

if you are working in the Flow Designer you can achieve this without scripting, you can:

 

  1. Add a Look Up Record activity to your location mapping table "x_ibmip_tktrouting_location_routing" with the correct filter conditions.
  2. Update the wanted record with the date from the record you got in the Look Up Record activity

 

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

Hello Steve,

 

I have tried it but how to update the record by getting the value, as we have multiple values under the fileter condition about 96 records.

Hello @Srilakshmi7 ,

can you please explain what values you want to update on the records with what values from "x_ibmip_tktrouting_location_routing". Because if the '"x_ibmip_tktrouting_location_routing" is a mapping table it should correspond to only one assignment group for that location.

When you find the assignment group for that location, what field on what record do you want to update?