Recalculate Cost Plan Breakdown with New Exchange Rate

Deepak Negi
Mega Sage
Mega Sage

Hi

 

We have updated new FX Rates for the FY.

There are some existing cost plans which had the calculations done from previous exchange rate. Now we want those Cost plan/Breakdowns to be recalculated according to new Exchange rates.

What is the best way to re-run the calculations?

 

I tried writing a background script to update the Exchange rate for breakdowns but it did not work. Any other ideas?

 

Regards

Deepak

 

1 REPLY 1

Rajesh_Singh
Kilo Sage
Kilo Sage

Since your initial attempt didn't work, I suggest trying the following background script:

// Update cost plans
var costPlan = new GlideRecord('cost_plan');
costPlan.query();

while (costPlan.next()) {
    // Make any update on the record to trigger the recalculations
    costPlan.setValue('short_description', costPlan.getValue('short_description'));
    costPlan.update();
}

// Update cost plan breakdowns
var costPlanBreakdown = new GlideRecord('cost_plan_breakdown');
costPlanBreakdown.query();

while (costPlanBreakdown.next()) {
    // Make any update on the record to trigger the recalculations
    costPlanBreakdown.setValue('short_description', costPlanBreakdown.getValue('short_description'));
    costPlanBreakdown.update();
}

This script updates the cost plan and breakdown records by setting the short_description field to its current value, triggering a recalculation based on the new exchange rates. Make sure to test this script in a development

If this approach still doesn't work, there might be other factors or customizations in your instance affecting the calculation. In that case, you might need to review your cost plan and breakdown logic, as well as any relevant business rules, to identify the root cause of the issue.

If you found my response helpful or applicable, please consider marking it as correct or helpful to assist others who may be seeking the same information.

---------------
Regards,
Rajesh Singh