FinancialsWidgetUtil - Scoped

  • Release version: Xanadu
  • Updated August 1, 2024
  • 5 minutes to read
  • 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.
    Figure 1. Financials section in Project Workspace
    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.

    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.

    Table 1. Parameters
    Name Type Description
    investmentGr GlideRecord Investment to get aggregate values for. Located in the Investment [sn_invst_pln_invst_investment] table.
    timeScope Object Object containing the fiscal periods to use as the start and end dates for the aggregation.
    { 
       "startFiscalPeriodSysId": "String", 
       "endFiscalPeriodSysId": "String" 
    } 
    timeScope.startFiscalPeriodSysId String Sys_id of the fiscal period to use as the start date for the aggregation. Located in the Fiscal Period [fiscal_period] table.
    timeScope.endFiscalPeriodSysId String Sys_id of the fiscal period to use as the end date for the aggregation. Located in the Fiscal Period [fiscal_period] table.
    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.

    Table 2. Parameters
    Name Type Description
    None
    Table 3. Returns
    Type Description
    Object

    Object containing the display value and value for the actual cost.

    { 
       "displayValue": "String", 
       "value": Number
    }
    <Object>.displayValue Display value of the actual cost, such as $1.00 K.

    Data type: String

    <Object>.value Value of the actual cost, such as 1000.

    Data type: Number

    This example adds a child widget to the Actual Cost to Date widget that shows the actual 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').getActuals();
          return {
             displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(opexCost.value),
             value: opexCost.value
          };
       }
    })();

    FinancialsWidgetUtil - getBudget()

    Returns the budget for any planning items and work items linked to an investment.

    To use this method, create a child widget with the Budget widget as the parent. Use this method in the Script field of the child widget record.

    The budget returned by this method is for the time period and expense type specified when instantiating the FinancialsWidgetUtil object.

    Table 4. Parameters
    Name Type Description
    None
    Table 5. Returns
    Type Description
    Object

    Object containing the display value and value for the budget.

    { 
       "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.

    Table 6. Parameters
    Name Type Description
    None
    Table 7. Returns
    Type Description
    Object

    Object containing the display value and value for the EAC.

    { 
       "displayValue": "String", 
       "value": Number
    }
    <Object>.displayValue Display value of the EAC, such as $2.38 K.

    Data type: String

    <Object>.value Value of the EAC, such as 2380.

    Data type: Number

    This example adds a child widget to the Estimate at Completion widget that shows the EAC 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').getEAC();
          return {
             displayValue: PPMCurrencyHelper.getFormattedAmountWithCurrency(opexCost.value),
             value: opexCost.value
          };
       }
    })();

    FinancialsWidgetUtil - getPlannedCost()

    Returns the planned cost for any planning items and work items linked to an investment.

    To use this method, create a child widget with the Planned Cost widget as the parent. Use this method in the Script field of the child widget record.

    The planned cost returned by this method is for the time period and expense type specified when instantiating the FinancialsWidgetUtil object.

    Table 8. Parameters
    Name Type Description
    None
    Table 9. Returns
    Type Description
    Object

    Object containing the display value and value for the planned cost.

    { 
       "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
          };
       }
    })();