- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 03:11 PM
SCENARIO:
Resource plan created, generating requested_allocations. resource_plan.planned_cost calculates correctly since its using the group_resource rate.
Because of the FiretrUCKING Labor Rate Card table swapping bug, hundreds of allocations have been created with the wrong resource_allocation.allocated_cost. That means resource_plan.allocated_cost is also borked.
Deconstructing the ResourcePlan script include I've found functions that allow me to recalculate planned cost, however no functions appear to recalculate and update a resource_allocation's allocated_cost, then recalculate the resource_plan.allocated_cost.
Anyone have any insights?
Here's a script I've been working with. updatePlanned() works, but updateAllocated() does nothing.
function updatePlanned(req) {
var resourcePlan = new ResourcePlan();
resourcePlan.get(req.getValue('resource_plan'));
resourcePlan.updatePlannedHoursAndCost(req.getTableName());
}
function updateAllocated(alloc){
gs.print('in updateAllocated');
var allocation = new ResourceAllocation(alloc);
allocation.calculateAllocatedCost();
var resourcePlan = new ResourcePlan();
//gs.print(alloc.getValue('resource_plan'));
resourcePlan.get(alloc.getValue('resource_plan'));
//resourcePlan.updateAllocatedCost();
resourcePlan.updateAllocatedHoursAndCost();
}
var rp = new GlideRecord('resource_plan');
rp.get('37313f471383e34084b3b7a66144b00c'); //my sample Resource Plan
gs.print(rp.short_description);
var rpreqs = new GlideRecord('requested_allocation');
rpreqs.addQuery('resource_plan',rp.sys_id);
rpreqs.query();
while (rpreqs.next()){
updatePlanned(rpreqs);
}
var rpallocs = new GlideRecord('resource_allocation');
rpallocs.addQuery('resource_plan',rp.sys_id);
rpallocs.query();
while (rpallocs.next()){
gs.print('Launch updateAllocated');
updateAllocated(rpallocs);
}
Solved! Go to Solution.
- Labels:
-
Resource Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 05:20 AM
Hi Robert,
Can you change the below function from
function updateAllocated(alloc){
gs.print('in updateAllocated');
var allocation = new ResourceAllocation(alloc);
allocation.calculateAllocatedCost();
var resourcePlan = new ResourcePlan();
//gs.print(alloc.getValue('resource_plan'));
resourcePlan.get(alloc.getValue('resource_plan'));
//resourcePlan.updateAllocatedCost();
resourcePlan.updateAllocatedHoursAndCost();
}
to
function updateAllocated(alloc){
var allocation = new ResourceAllocation(alloc);
allocation.updateAllocatedHoursAndCost();
var resourcePlan = new ResourcePlan();
resourcePlan.get(alloc.getValue('resource_plan'));
resourcePlan.updateAllocatedHoursAndCost();
}
and execute this. Try executing this in some temp instance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 06:59 PM
There is out of box BR: Recreate Requested Allocations, that looks like it doesn't run when Allocated, but maybe you can use the script to force recalcs?
var rp = new ResourcePlan();
rp.get('37313f471383e34084b3b7a66144b00c');
rp.reCreateRequestedAllocations();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 03:50 AM
I'll give that one a shot, but I'm doubting it. I can get the requested allocations to update just fine. Its the resource_allocations that I can't get to budge.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 05:03 AM
Hi Robert,
can you change your function from
function updateAllocated(alloc){
gs.print('in updateAllocated');
var allocation = new ResourceAllocation(alloc);
allocation.calculateAllocatedCost();
var resourcePlan = new ResourcePlan();
//gs.print(alloc.getValue('resource_plan'));
resourcePlan.get(alloc.getValue('resource_plan'));
//resourcePlan.updateAllocatedCost();
resourcePlan.updateAllocatedHoursAndCost();
}
to
function updateAllocated(alloc){
var allocation = new ResourceAllocation(alloc);
allocation.updateAllocatedHoursAndCost();
var resourcePlan = new ResourcePlan();
resourcePlan.get(alloc.getValue('resource_plan'));
resourcePlan.updateAllocatedHoursAndCost();
}
and execute.
Let me know whether it has corrected both resource_allocation.allocated_cost and resourceplan.allocated_cost? Try this in clone instance.
Thanks,
Harsha Lanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 05:20 AM
Hi Robert,
Can you change the below function from
function updateAllocated(alloc){
gs.print('in updateAllocated');
var allocation = new ResourceAllocation(alloc);
allocation.calculateAllocatedCost();
var resourcePlan = new ResourcePlan();
//gs.print(alloc.getValue('resource_plan'));
resourcePlan.get(alloc.getValue('resource_plan'));
//resourcePlan.updateAllocatedCost();
resourcePlan.updateAllocatedHoursAndCost();
}
to
function updateAllocated(alloc){
var allocation = new ResourceAllocation(alloc);
allocation.updateAllocatedHoursAndCost();
var resourcePlan = new ResourcePlan();
resourcePlan.get(alloc.getValue('resource_plan'));
resourcePlan.updateAllocatedHoursAndCost();
}
and execute this. Try executing this in some temp instance.