FinancialsWidgetUtil- Scoped
The FinancialsWidgetUtil script include provides methods to customize widgets in the Financials section of Project Workspace and Strategic Planning Workspace.
The following widgets are available in Project Workspace and Strategic Planning Workspace by default.
- Budget
- Estimate at Completion
- Planned Cost
- Actual Cost to Date
You can use the FinancialsWidgetUtil script include to add child widgets that show values for a specified time period or expense type.
This screenshot shows widgets for Budget, Estimate at Completion, Budget vs EAC Variance, Planned Cost, and Actual Cost to Date.
In this example from Project Workspace, the Planned Cost widget has child widgets that show CapEx and OpEx values, while the Budget widget doesn't have any child widgets.
To use this script include, create a child widget with one of the available financials widgets as the parent. Use the methods from this script include in the Script field of the child widget record.
The FinancialsWidgetUtil script include requires the Financials Core application (sn_invst_pln), as well as the Strategic Planning application (sn_apw_advanced) or Project Workspace application (sn_pw). This script include is provided within the sn_invst_pln namespace.
Parent Topic:Server API reference
FinancialsWidgetUtil - FinancialsWidgetUtil(GlideRecord investmentGr, Object timeScope, String expenseType)
Instantiates a FinancialsWidgetUtil object.
This object is used to get aggregate values such as budget and planned cost for an investment.
| Name | Type | Description |
|---|---|---|
| investmentGr | GlideRecord | Investment to get aggregate values for.Table: Investment \[sn\_invst\_pln\_invst\_investment\] |
| timeScope | Object | List of fiscal periods to use as the start and end dates for the aggregation. |
| timeScope.startFiscalPeriodSysId | String | Sys\_id of the fiscal period to use as the start date for the aggregation.Table: Fiscal Period \[fiscal\_period\] |
| timeScope.endFiscalPeriodSysId | String | Sys\_id of the fiscal period to use as the end date for the aggregation.Table: Fiscal Period \[fiscal\_period\] |
| expenseType | String | Optional. Type of expense to include in the aggregation, such as capital expenditure \(CapEx\) or operating expense \(OpEx\).Valid values: - capex - opex |
This example instantiates a FinancialsWidgetUtil object that can be used to return aggregate values for an investment where the expense type is CapEx and the time period is context.timeScope.
var context = JSON.parse(context);
var investment = context.investment;
(function initializeFWU() {
var invGr = new GlideRecord('sn_invst_pln_invst_investment');
if (invGr.get(investment.sys_id)) {
var capexCost = new sn_invst_pln.FinancialsWidgetUtil(invGr, context.timeScope, 'capex');
}
})();
FinancialsWidgetUtil - getActuals()
Returns the actual cost for any planning items and work items linked to an investment.
To use this method, create a child widget with the Actual Cost to Date widget as the parent. Use this method in the Script field of the child widget record.
The actual cost returned by this method is for the time period and expense type specified when instantiating the FinancialsWidgetUtil object.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| Object | Object containing the display value and value for the actual cost. ``` { "displayValue": "String", "value": Number } |
| <Object>.displayValue | Display value of the budget, such as `$2.50 K`.Data type: String |
| <Object>.value | Value of the budget, such as `2500`.Data type: Number |
This example adds a child widget to the Budget widget that shows the budget for OpEx only.
var context = JSON.parse(context);
var investment = context.investment;
(function getCost() {
var invGr = new GlideRecord('sn_invst_pln_invst_investment');
if (invGr.get(investment.sys_id)) {
var opexCost = new sn_invst_pln.FinancialsWidgetUtil(invGr, context.timeScope, 'opex').getBudget();
return {
displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(opexCost.value),
value: opexCost.value
};
}
})();
FinancialsWidgetUtil - getEAC()
Returns the estimate at completion (EAC) value for any planning items and work items linked to an investment.
To use this method, create a child widget with the Estimate at Completion widget as the parent. Use this method in the Script field of the child widget record.
The EAC value returned by this method is for the time period and expense type specified when instantiating the FinancialsWidgetUtil object.
| Name | Type | Description |
|---|---|---|
| None |
| Type | Description |
|---|---|
| Object | Object containing the display value and value for the EAC. ``` { "displayValue": "String", "value": Number } |
| <Object>.displayValue | Display value of the planned cost, such as `$4.05 K`.Data type: String |
| <Object>.value | Value of the planned cost, such as `4050`.Data type: Number |
This example adds a child widget to the Planned Cost widget that shows the planned cost for OpEx only.
var context = JSON.parse(context);
var investment = context.investment;
(function getCost() {
var invGr = new GlideRecord('sn_invst_pln_invst_investment');
if (invGr.get(investment.sys_id)) {
var opexCost = new sn_invst_pln.FinancialsWidgetUtil(invGr, context.timeScope, 'opex').getPlannedCost();
return {
displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(opexCost.value),
value: opexCost.value
};
}
})();