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

Delete Employee Profiles

gjz
Mega Sage

I'm am starting the process of migrating to the new Resource Assignments from Resource Plan and have run into an issue in my sub-prod instance.  When I generated the Employee Profiles, I see I have a lot of records that should not be there because they have the pps_resource role, but they will never be considered for a resource assignment.  I would like to delete all the records and add additional criteria to create the correct employee records, but I don't see an option to delete the records and I assume that is for a reason.

 

What is the impact if I delete all the records prior to moving forward with the Resource Migration?  Obviously, deleting records should not be done once there are resource assignments or migrated resource plans, I want to delete them before I continue.

1 REPLY 1

MaxMixali
Kilo Guru

ServiceNow – Employee Profile Cleanup Before Resource Assignment Migration

Question:
During migration from Resource Plans to the new Resource Assignments, I generated Employee Profiles and discovered that many records were created incorrectly (users with pps_resource role but not actual assignable resources). I’d like to delete all Employee Profiles and rebuild them with refined criteria before continuing. Is this safe?

Answer:
Yes, it is technically possible to delete Employee Profiles before migration, provided no actual Resource Assignments or migrated Resource Plans exist yet. However, there are key considerations and best practices to follow to avoid breaking relationships or orphaning data.

---

1. Understanding Employee Profiles
- Table: resource_employee_profile
- Purpose: acts as the “resource identity” record linking users, skills, calendars, and availability.
- Generated automatically from Resource Migration Utility or manually via Employee Profile generation job.
- Once resource assignments exist, these profiles become linked to allocation, cost plan, and utilization data.

---

2. When It’s Safe to Delete
SAFE TO DELETE IF:
- No records exist in:
- resource_allocation
- resource_assignment
- resource_plan_migration
- You have not yet executed the “Migrate Resource Plans to Resource Assignments” job.
- You’re still in pre-migration validation and testing phase (sub-prod or dev).

DO NOT DELETE IF:
- Any resource plan or assignment references these profiles.
- The migration job has already run partially — this could orphan references in resource_allocation or project_task_assignment tables.

---

3. Deletion Method
Employee Profile deletion is restricted (no delete UI action) to prevent accidental data loss in production.
Options to delete safely:
a) Scripted deletion in sub-prod:
```
var profiles = new GlideRecord('resource_employee_profile');
profiles.query();
while (profiles.next()) {
profiles.deleteRecord();
}
```
b) Add criteria if you only want to delete specific profiles (e.g. system-generated ones):
```
profiles.addQuery('u_is_generated', true);
profiles.query();
...
```
c) Never mass-delete in production; validate first in sub-prod.

---

4. Rebuilding Employee Profiles with Correct Criteria
- Go to **Resource Management > Administration > Employee Profile Generation**.
- Adjust the filtering logic to exclude:
- Users without cost center or department.
- Users not marked as assignable.
- Contractors or roles outside delivery functions.
- You can modify the generation script include **“GenerateEmployeeProfiles”** or equivalent utility parameters.
- Rerun generation job; verify counts and sample profiles.

Optional: add a condition in script to check roles dynamically, e.g.:
```
if (!user.hasRole('resource_assignable')) return; // skip
```

---

5. Impact of Deletion (Pre-Migration)
- No system impact if assignments don’t exist.
- You’ll regenerate profiles cleanly with proper logic.
- Audit logs (sys_audit) may record deletions, but those are harmless for sub-prod.
- Avoid deleting after migration, as migrated resource plans reference employee_profile.sys_id.

---

6. Best Practice Migration Sequence
1. Snapshot current data for rollback reference.
2. Delete existing employee profiles (only in sub-prod, before migration).
3. Adjust generation filter (Script Include or system property).
4. Regenerate employee profiles.
5. Validate sample profile mapping: user, department, resource group, cost center.
6. Proceed with Resource Migration Utility.
7. Validate migrated assignments; compare resource utilization before and after.

---

7. Key Takeaway
Deleting Employee Profiles is safe *only before* running the Resource Migration job, and only in environments without resource assignments. Once assignments exist, deletion breaks relationships. Perform the cleanup early, refine generation criteria, and regenerate profiles with accurate filtering to ensure a clean and compliant migration.

---

Summary Table
| Scenario | Safe to Delete? | Recommended Action |
|-----------|----------------|--------------------|
| No resource assignments, pre-migration | Yes | Delete & regenerate |
| After migration or assignments exist | No | Use update/deactivation instead |
| Sub-prod testing phase | Yes | Safe cleanup |
| Production post-migration | No | Do not delete |

Conclusion:
Before Resource Migration, deleting all Employee Profiles is safe if done in a clean environment with no migrated data. Adjust your generation logic, regenerate the profiles, and proceed with migration. After migration, never delete profiles — deactivate or update instead.