The CreatorCon Call for Content is officially open! Get started here.

Populate Assignment group Asset reclamation task

Arun Priya
Tera Contributor

Hi All,

I need to auto populate Assignment group in "asset reclamation task" based on the Requested for location managed by group.
This asset reclamation request are raised from a record producer.

 

Can some one help me to understand on how to implement this requirement.

 

1 ACCEPTED SOLUTION

Siddhesh Wani1
Tera Guru

Hi @Arun Priya ,

There are two ways to achieve this 
1) You can created after insert BR for the "asset reclamation task" and then check for the requested by location and based on that you can populate the assignment group.
Script:
(function executeRule(current, previous /*null when async*/) {
// Get Requested For user's location
var requestedFor = current.u_requested_for; // Replace with your actual field
var userGR = new GlideRecord('sys_user');
if (userGR.get(requestedFor)) {
var locationSysId = userGR.location; // Reference field

// Look up group managing this location
var locationGR = new GlideRecord('cmn_location');
if (locationGR.get(locationSysId)) {
var managedByGroup = locationGR.u_managed_by_group; // Replace with your actual field name
if (managedByGroup) {
current.assignment_group = managedByGroup;
}
}
}
})(current, previous);

2) You can use On submit catalog client script with similar logic. 
After submitting the record it will auto set the field with the group

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks 
Siddhesh

View solution in original post

26 REPLIES 26

From your explanation I understand that based on the location you are assigning different groups. So for example if you have region based group assignment say :- for EMEA region you have countries (Belgium , Netherlands , Sweden) you want to assign group DEMO 1 and for countries like (Dubai , Saudi Arabia) you want to assign DEMO 2 then you will have to make multiple assignment rules.

If you still have more doubts then I would like to know your requirement in a detailed manner.
Thanks.

To achieve this, you need to write a script that was provided by me previously in the record producer script field

Please hit like and mark my response as correct if that helps

Nehal Dhuri
Mega Sage

You can use the following script in the record producer script field 

current.assignment_group = producer.requested_for.location.managed_by_group

 

Please hit like and mark my response as correct if that helps

@Arun Priya In a ServiceNow record producer script, the current object represents the new record being created, while the producer object refers to the variables of the record producer itself, allowing you to map values from the variables to the new record's fields

Please hit like and mark my response as correct if that helps

Hello @Arun Priya ,
Have you been able to try my given solution?

Please hit like and mark my response as correct if that helps