How to set “Planned Benefit” and "Actual Benefit" to Project Workspace Financials Widgets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I would like to add “Planned Benefit” and "Actual Benefit" to Project Workspace Financials Widgets.
I changed the widget settings and they will be reflected as shown below.
However, there are currently two problems:
- The amount is displayed in two rows, one in red and one in black.
- Even when I enter values into "Planned Benefit" and "Actual Benefit," the value does not change from 0 yen, and the correct number is not displayed.
The current widget settings are as follows:
■Planned Benefit
■Actual Benefit(Designated as a child of Planned Benefit)
Could you please let me know if there is an error in the setup?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
42m ago - last edited 41m ago
Hello @WataruS,
The issue is with how the widget script fetches data. The context object doesn’t include benefits or actual_benefit, which is why you’re seeing 0 yen.
Try updating your script like below:
Planned Benefit:
var context = JSON.parse(context);
var investment = context.investment;
(function getPlannedBenefit() {
var invGR = new GlideRecord('sn_invst_pln_invst_investment');
if (invGR.get(investment.sys_id)) {
var plannedBenefit = invGR.getValue('planned_benefit');
return {
value: plannedBenefit,
displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(plannedBenefit)
};
}
})();
Actual Benefit:
var context = JSON.parse(context);
var investment = context.investment;
(function getActualBenefit() {
var invGR = new GlideRecord('sn_invst_pln_invst_investment');
if (invGR.get(investment.sys_id)) {
var actualBenefit = invGR.getValue('actual_benefit');
return {
value: actualBenefit,
displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(actualBenefit)
};
}
})();
Also, the two-row (red/black) display happens when both value and displayValue are formatted twice. Make sure your widget isn’t applying extra formatting rules.
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.