We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Restrict Data Import to Group-Specific Records in Hardware table

sattar3
Tera Contributor

 

Hello everyone,

 

We have a requirement to allow users to import data into the Hardware table (alm_hardware), with access restricted by a custom reference field u_managed_by_group (reference → sys_user_group). We have four distinct groups. Users should only be able to import records where u_managed_by_group matches their own group.

Example

  • Hardware AC team members can import assets only when Managed by group = Hardware AC.
  • Hardware DC team members must not be able to create/update records for Hardware AC, and vice versa.

By Using Data Sources we need to implement this, can someone suggest how to achieve requirement?

Any scripts needs to write?

 

@Ankur Bawiskar @Dr Atul G- LNG @Kieran Anson 


Thanks,

Sattar

2 REPLIES 2

yashkamde
Kilo Sage

Hello @sattar3 ,

 

I will recommend use Transform map script,
In the Transform Map, add an onBefore script that checks if the u_managed_by_group on the incoming record matches one of the current user’s groups (gs.getUser().getMyGroups()). If not, set ignore = true so the record is skipped.

Script :

var userGroups = gs.getUser().getMyGroups();
if (source.u_managed_by_group && userGroups.indexOf(source.u_managed_by_group) == -1) {
    ignore = true;
    gs.addInfoMessage("You are not allowed to import records for group: " + source.u_managed_by_group);
}

 

If my response helped mark as helpful and accept the solution.

Ankur Bawiskar
Tera Patron

@sattar3 

how are they importing?

share the screenshot

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