The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Cost plans - Migrating Resource Plans to Assignments

Alex2506
Tera Expert

Hi SPM Community, 

 

We're moving to Resource Assignments and we'd like to automate the creation of cost plans rather than using the UI action 'generate labor costs'. Using the code from this UI action, I created a business rule which seems to be working. 

 

However, when we migrate Resource Plans to assignments, it's creating new cost plans as technically new resource assignments are created in the system, thus the business rule runs. Has anyone got any suggestions to get around this or a better method of doing this?

 

Thank you! 

7 REPLIES 7

Vinay3
ServiceNow Employee
ServiceNow Employee

Hi @Alex2506 could you share more info about the logic used in the business rule to automate the creation of cost plans for resource assignments? Does it run the generate labor costs logic every time an update is made to resource assignment? Have you considered using the 'generate labor costs..' scheduled job thats available OOB to automate the creation of labor cost plans.

Regarding migrate resource plans, may be its better to disable the BR before the migration is done and enable it once all resource plans are migrated?

Hi @Vinay3 - That's exactly what we decided. We'll turn off the automation until all resource plans are migrated. Thanks for your reply!

Vinay3
ServiceNow Employee
ServiceNow Employee

@Alex2506 could you share more info about the logic used in the business rule to automate the creation of cost plans for resource assignments?

Hi @Vinay3 

It runs on the sn_plng_att_core_resource_assignment table. 

The logic is similar to the UI action. Is there any plan to automate this going forward? I know there's a scheduled job and a UI action but a requirement I've heard from customers is that they want cost plans in real time and sometimes users forget to click the UI action.

var project = null;
    if (current.task) {
        var taskGR = current.task.getRefRecord();

        if (taskGR.getTableName() === 'pm_project') {
            project = current.task;
        } else if (taskGR.top_task) {
            project = taskGR.top_task;

        }
    }

    if (project) {
try {
            var cp = new sn_plng_att_core.CostPlanForFinancialAttributes();
            cp.createCostPlan(project.toString(), 'pm_project');
            gs.info("AB2907 Created cost plans from resource allocations for Project " + project.toString());
        } catch (e) {
            gs.error("AB2907 Error during cost plan creation from resource allocations for Project " + project.toString());
            gs.error(JSON.stringify(e));
        }
    } else {
        gs.info("AB2907 error here");
    }