If Resource Plan is completed capacity in workbench is not updating

Chahak kindra
Tera Contributor

If Resource Plan is completed then capacity is Resource workbench is still showing same, it should be updated.

Example : If Resource Plan is completed for July month, Capacity is 30 hrs and allocated hours are 10 hrs then Availability is 20 hrs but as resource plan is already completed then Allocated hours should become 0 in this case and Availability should be 30 hrs.

 

How to achieve this, please assist.

 

Thanks,

Chahak

2 REPLIES 2

Roshnee Dash
Tera Guru

Hi @Chahak kindra 
You can once try like this.

Business Rule (Recommended for Real-time Updates)

  • Create a business rule on the resource_plan table.

  • Trigger it after update when the state of the Resource Plan changes to Completed.

  • Set the Allocated Hours to and update the Availability to match the Capacity.

(function executeRule(current, previous /*null when async*/) {
    if (current.state == 'completed') { // Ensure Resource Plan is completed
        var resourceWorkbench = new GlideRecord('resource_workbench'); // Adjust table name if needed
        resourceWorkbench.addQuery('resource_plan', current.sys_id);
        resourceWorkbench.query();
        
        while (resourceWorkbench.next()) {
            resourceWorkbench.allocated_hours = 0;
            resourceWorkbench.availability = resourceWorkbench.capacity; // Reset availability
            resourceWorkbench.update();
        }
    }
})(current, previous);
  • Scheduled Job (For Periodic Updates)

    • If real-time updates are not required, create a scheduled job to run daily or weekly.

    • It will check for completed Resource Plans and update the Allocated Hours accordingly.

  • Ensure Data Integrity

    • Verify that the Resource Workbench table correctly reflects the Capacity and Availability fields.

    • If necessary, update the Resource Allocation Workbench logic to reflect these changes.

Your feedback makes the community stronger! If you found this helpful, marking it as the correct answer helps others.
Stay awesome,
Roshnee Dash

Hi @Chahak kindra 

If you found my response helpful, please mark it as correct and close the thread so others can benefit from it too.

Your feedback makes the community stronger! If you found this helpful, marking it as the correct answer helps others.
Stay awesome,
Roshnee Dash