- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 09:14 PM
I have 2 resource plans created for the same users in Project (pm_project).
- The first resource plan has start date = 01-05-2023 and end date = 31-12-2023
- The second one has Start Date = 01-01-2024 and end Date 31-03-2024
I tried to cancel and remove the second resource plan but inside table Resource Aggregates Weekly it still contains weeks of the second resource plan. Is there any process I need to do more to recalculate Resource Aggregates Weekly for this user ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 09:39 PM
Update Resource Aggregates (Manual):
* Purpose: This function manually recalculates the resource aggregates for a specific user and time period.
* Steps:
1. Go to the User record in the Resource Management module.
2. Find the Related Links section and click on Update Resource Aggregates.
3. In the dialog box, enter the Start Date and End Date to cover the period where you canceled the resource plan.
4. Click OK to initiate the recalculation.
2. Scheduled Job (Automated):
* Purpose: ServiceNow has a scheduled job that automatically updates resource aggregates periodically.
* Job Name: "Update Resource Aggregates."
* Configuration: You can find this job in System Definition > Scheduled Jobs. If it's not active, you can activate it and adjust the frequency if needed.
There is a script template that I follow on my ServiceNow project works and copied it below - You can adjust the script accordingly if you are a developer OR You can share it with your developer team members
// Assuming you want to update weekly aggregates for a specific user
var userSysId = 'your_user_sys_id'; // Replace with the actual sys_id
var startDate = '2024-01-01'; // Start date of the period to update
var endDate = '2024-03-31'; // End date of the period to update
// Query for the weekly aggregates for this user and period
var gr = new GlideRecord('resource_aggregate_weekly');
gr.addQuery('user', userSysId);
gr.addQuery('week_starts_on', '>=', startDate);
gr.addQuery('week_starts_on', '<=', endDate);
gr.query();
while (gr.next()) {
// Recalculate allocated and available hours based on your logic
var allocatedHours = calculateAllocatedHours(gr.user, gr.week_starts_on); // Your custom function
var availableHours = calculateAvailableHours(gr.user, gr.week_starts_on); // Your custom function
// Update the aggregate record
gr.setValue('allocated_hours', allocatedHours);
gr.setValue('available_hours', availableHours);
gr.update();
}
3. Manual Table Update (Advanced):
* Caution: Directly modifying database tables should be done with extreme caution and only by experienced administrators, as it can have unintended consequences.
* Steps:
1. Navigate to the resource_aggregate_weekly table.
2. Find the records corresponding to the user and the weeks affected by the canceled resource plan.
3. Manually correct the data in the aggregate fields (e.g., allocated_hours, available_hours).
4. Be sure to double-check your calculations before saving.
Important Considerations:
* Data Consistency: Ensure that the data in the Resource Plan ( resource_plan) and Resource Allocation ( resource_allocation) tables accurately reflect the cancelled resource plan.
* Data Discrepancies: If you continue to see discrepancies, investigate further by checking the Resource Allocation Time Card (resource_allocation_time_card) and Resource Allocation Daily (resource_allocation_daily) tables for any leftover allocations related to the cancelled plan.
If you like this opinion. Please kindly mark this your best answer OR Helpful and help me to contribute more to this community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 02:55 AM
I'm glad that my solution helps you in some way.
Please subscribe to Monthly ServiceNow Digest Nothing But Tables&Columns on Linkedin to get updated on latest discussion and feature on ServiceNow Feature and capabilities
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community