People Data import design
Data is sourced from the IDR system
The IDR system provides versioned people data. Records come with an I(Insert),U(Update) or D(Delete) operation. We don't delete records in our system so in this case we will mark them as inactive.
If a person is marked as inactive we will remove them as members from any group and as queue manager in all groups. This is done via an on after script:
/** * Determine if a user is active or not **/ if (source.u_hasaffiliaterole == "Y" || source.u_hasalumnusrole == "Y" || source.u_hasemployeerole == "Y" || source.u_hasfacultyrole == "Y" || source.u_hasmemberrole == "Y" || source.u_hasstaffrole == "Y" || source.u_hasstudentrole == "Y"){ // If a user has any role they are considered active target.active = true; }else if(source.u_operation == "D"){ // If they are marked as delete, set them as inactive target.active = false; }else{ // No role and not a delete, they are inactive target.active = false; removeFromGroups(); removeFromQueues(); } function removeFromGroups(){ // Remove inactive user from groups var gr = new GlideRecord('sys_user_grmember'); gr.addQuery('user.u_upi',target.u_upi); gr.query(); gr.deleteMultiple(); } function removeFromQueues(){ // Remove inactive user from queues //Get all groups that this user is a queue manager in var aUtil = new ArrayUtil(); var grUserGroup = new GlideRecord('sys_user_group'); grUserGroup.addQuery('u_queue_managers','CONTAINS',target.sys_id); grUserGroup.query(); while(grUserGroup.next()){ removeAsQueueManager(); } function removeAsQueueManager(){ var managers; if (grUserGroup.u_queue_managers){ managers = grUserGroup.u_queue_managers.split(","); managers = aUtil.unique(managers); var queueMangerList; // Make sure they're in the list before we try and remove them if (aUtil.contains(managers,'52fd05c56f02f1007ee2abcf9f3ee426')){ var removed = managers.splice(aUtil.indexOf(managers,'52fd05c56f02f1007ee2abcf9f3ee426'), 1); // Get the new manager list with the user removed queueMangerList = aUtil.diff(managers,removed); } // Make sure we have changes to make, since someone might request a person that already has access if (queueMangerList){ grUserGroup.u_queue_managers = queueMangerList.toString(); grUserGroup.update(); } } } }