Recalculate Cost Plan Breakdown with New Exchange Rate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 01:01 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 06:28 AM
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.
---------------
Regards,
Rajesh Singh