Calculating Scores from Numeric Fields and Updating Custom Fact Sheet Fields

Learn how to set up a custom calculation using the inboundFactSheet processor of the Integration API. The processor calculates risk scores from numeric fields and writes the calculated score and mapped risk tier to custom fact sheet fields.

Overview

You can use the Integration API to set up custom calculations for fact sheet fields. In this tutorial, you'll learn how to configure an inboundFactSheet processor to perform calculations and update custom fact sheet fields. The configuration includes three processors that run sequentially to:

  1. Read values from two numeric fields and calculate the total risk score.
  2. Write the total calculated score to a custom fact sheet field.
  3. Map the total risk score to a user-friendly risk tier and write the tier to a custom fact sheet field.

Alternatively, you can set up calculations using trigger-based automations. In this method, a webhook triggers a calculation whenever a specific fact sheet field is updated. For tutorials on setting up trigger-based automations for calculations, please visit:

Prerequisites

You need an admin role for your SAP LeanIX workspace.

This tutorial assumes you have a basic understanding of:

Step 1: Create Custom Fact Sheet Fields

The processor in this tutorial is configured for application fact sheets. In the meta model configuration, create custom fields on the application fact sheet for individual risk scores, total risk score, and risk tier. To learn more about fact sheet configuration and fields, refer to:

To create custom fields, follow these steps:

  1. In the administration area, navigate to the Meta Model Configuration section.

  2. Select the application fact sheet.

  3. Create a subsection for risk assessment by clicking Add subsection. Alternatively, you can add custom fields to an existing subsection.

  4. To create custom fields within a subsection, click Add field and configure each field in the right-side panel. For details, refer to the following table. You can generate labels and help texts using AI-supported translation.

  5. Save the changes.

KeyField TypeDisplayed AsValues and Labels
InfrastructureRiskScoreIntegerNumberN/a
ApplicationOperationalRiskScoreIntegerNumberN/a
TotalRiskScoreIntegerNumberN/a
RiskTierSingle SelectStatus- Green
- Yellow
- Orange
- Red

The following image shows how custom fields appear on the application fact sheet.

Custom Subsection "Risk Assessment" with Custom Fields on the Application Fact Sheet

Custom Subsection "Risk Assessment" with Custom Fields on the Application Fact Sheet

Step 2: Map Risk Scores to Risk Tiers

Map the total risk score to a user-friendly risk tier. Here's an example mapping:

Risk ScoreRisk Tier
< 10Green
10–16Yellow
17–23Orange
> 23Red

Include these mappings in the processor configuration, as described in the following step.

{
  "key": {
    "expr": "RiskTier"
  },
  "values": [
    {
      "expr": "${ lx.factsheet.TotalRiskScore < 10 ? 'Green' : lx.factsheet.TotalRiskScore < 17 ? 'Yellow' : lx.factsheet.TotalRiskScore < 24 ? 'Orange' : lx.factsheet.TotalRiskScore > 23 ? 'Red' : null}"
    }
  ]
}

Step 3: Configure a Connector

To configure and run a connector, follow these steps:

  1. Go to the Integration API section in the administration area.
  2. Click New Processor Configuration, fill in the required details, and then click Create.
  3. On the connector configuration page, enter processors in the left-side section. For details, see Processor Configuration.
  4. In the Input section on the right, enter the input data. For details, see Input Data.
  5. To start a test run, click Test run. If successful, proceed to the next step.
  6. To start a run, click Run.
  7. To save the connector, click Save in the lower-left corner.

👍

Tip

You can configure the processor to run automatically every day, keeping your inventory data up to date. To learn how to configure daily runs, refer to Configuring Automated Nightly Runs for Integration API Processors.

Processor Steps

The connector includes three processors that perform these tasks:

  1. Read values from the InfrastructureRiskScore and ApplicationOperationalRiskScore numeric fields and store them in the TotalRiskScore variable.
  2. Write the calculated total risk score to the TotalRiskScore field.
  3. Map the total risk score to a user-friendly risk tier and write it to the RiskTier field.

👍

Tip

When specifying multiple processors in the configuration, use the run attribute to set the execution order. Numeration starts at 0, so the processor with "run": 0 runs first, the processor with "run": 1 runs second, and so on.

Processor Configuration

Example processor configuration:

{
  "processors": [
    {
      "processorType": "inboundFactSheet",
      "processorName": "1. Gather scores and store in variables",
      "processorDescription": "Gather Scores and Store in Variables",
      "type": "Application",
      "identifier": {
        "search": {
          "scope": {
            "ids": [],
            "facetFilters": [
              {
                "keys": [
                  "Application"
                ],
                "facetKey": "FactSheetTypes",
                "operator": "OR"
              }
            ]
          }
        }
      },
      "run": 0,
      "enabled": true,
      "variables": [
        {
          "key": "${lx.factsheet.id.concat('_TotalRiskScore')}",
          "value": "${helper:toList(lx.factsheet.InfrastructureRiskScore,lx.factsheet.ApplicationOperationalRiskScore)}"
        }
      ],
      "read": {
        "fields": [
          "InfrastructureRiskScore",
          "ApplicationOperationalRiskScore"
        ]
      }
    },
    {
      "processorType": "inboundFactSheet",
      "processorName": "2. Write total risk score",
      "processorDescription": "Gather Scores and Store in Variables",
      "type": "Application",
      "identifier": {
        "search": {
          "scope": {
            "ids": [],
            "facetFilters": [
              {
                "keys": [
                  "Application"
                ],
                "facetKey": "FactSheetTypes",
                "operator": "OR"
              }
            ]
          }
        }
      },
      "run": 1,
      "updates": [
        {
          "key": {
            "expr": "TotalRiskScore"
          },
          "values": [
            {
              "expr": "${variables[lx.factsheet.id.concat('_TotalRiskScore')].getNumbers().sum() != 0 ? variables[lx.factsheet.id.concat('_TotalRiskScore')].getNumbers().sum() : null }"
            }
          ]
        }
      ],
      "enabled": true
    },
    {
      "processorType": "inboundFactSheet",
      "processorName": "3. Write Risk Tier",
      "processorDescription": "Assign Risk Tier based on Total Risk Score",
      "type": "Application",
      "identifier": {
        "search": {
          "scope": {
            "ids": [],
            "facetFilters": [
              {
                "keys": [
                  "Application"
                ],
                "facetKey": "FactSheetTypes",
                "operator": "OR"
              }
            ]
          }
        }
      },
      "run": 2,
      "updates": [
        {
          "key": {
            "expr": "RiskTier"
          },
          "values": [
            {
              "expr": "${ lx.factsheet.TotalRiskScore < 10 ? 'Green' : lx.factsheet.TotalRiskScore < 17 ? 'Yellow' : lx.factsheet.TotalRiskScore < 24 ? 'Orange' : lx.factsheet.TotalRiskScore > 23 ? 'Red' : null}"
            }
          ]
        }
      ],
      "enabled": true,
      "read": {
        "fields": [
          "TotalRiskScore"
        ]
      }
    }
  ],
  "variables": {}
}

Input Data

Example input data:

{
  "connectorType": "DerivedScoring",
  "connectorId": "DerivedScoring",
  "connectorVersion": "1.0.0",
  "lxVersion": "1.0.0",
  "description": "",
  "processingDirection": "inbound",
  "processingMode": "partial",
  "customFields": {},
  "content": [
    {
      "type": "",
      "id": "",
      "data": {}
    }
  ]
}

Summary

In this tutorial, you learned how to configure an inboundFactSheet processor to perform calculations and update custom fact sheet fields.