SAP Knowledge Base Article - Public

3652095 - Create a Business Rule that Calculates and displays a Custom field in the Format X Years Y Months

Symptom

Create a Business Rule that Calculates and displays a Custom field in the Format X Years Y Months

"Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental."

Environment

  • SAP SuccessFactors HCM Suite
  • SAP SuccessFactors People Analytics
  • SAP SuccessFactors Employee Central

Resolution

 For any EC Standard field creation please refer to Guide: Data Model Field Information for Employee Central -

Step 1: Create  custom Field

Via : BCUI

  1. Go to Manage business configuration ( BCUI) 
  2. Scroll to:  employmentInfo
  3. enable custom-string1
  4. save 

Or

Via Code SDM Data Model 

Add below code

    Under: employmentInfo

<hris-field id="custom-string1" visibility="both">
      <label xml:lang="en-US">Time Service in format years and months</label>      
      <label>Time Service in format years and months</label>
    </hris-field>

Step 2: Grant RBP Permission To Custom Field

  1. Admin Center > Manage Permission Roles;
  2. Choose a Role;
  3. Scroll down to: employee data 
  4. check Your custom field
  5. grant View permission
  6. Save

    Step 3: Create  Rule

    • Go to Configure Business Rules
    • click on: Employee Central Core 
    • Select Trigger onView Rules for HRIS Elements

    You can use this scenario to create rules that default the value for a field, change field properties, or calculate fields that are transient (this means that the result is not a fixed value stored on the database but is calculated during rule execution when the user calls up the page). In Manage Business Configuration, rules created using this scenario can be used only for the onView event type.

    • View Test Example Rule

    Step 4: Add onView Rule under  Employment Details element - either via SDM Data model or Manage business configuration ( BCUI)

    Step 5: Review rule result in UI

    NOTE:Just a quick note on onView calculated fields:

    • Calculated fields are transient fields, meaning they are not stored in the database.
    • Instead, values are calculated dynamically each time you view a user’s Biographical Information.
    • Because of this, these fields are not supported for reporting and will not be available in reports when the rule is set to trigger onView.

    FAQ - Additional Information

    Q) Where can I get information on this from the Guide?

    A) Guide:Implementing Employee Central Core   /     Chapter:Rule Scenarios for Employee Central Core

        Guide: EC Standard field  Guide: Data Model Field Information for Employee Central -

    Q) Can I run a report on transient field?

    A) Just a quick note on onView calculated fields:

    • Calculated fields are transient fields, meaning they are not stored in the database.
    • Instead, values are calculated dynamically each time you view a user’s Biographical Information.
    • Because of this, these fields are not supported for reporting and will not be available in reports when the rule is set to trigger onView.

    See Also

    • 2283381 - Calculated / Transient fields are inconsistent or blank in reporting

    • 2345108 - How to Create a Business Rule to Calculate User Age
    • 2364155 - Age field not displaying values in Advanced Reporting
    • 2577292 - How to calculate age on a specific event date in Online Report Designer?
    • 2571171 - How to create a Age calculation field in Integration Center
    • 2515212 - How to get "number of years" an employee is working in the organization in ORD or Advance Reporting?
    • 2431354 - How to calculate the service anniversary (seniority) of an Employee who had break in service 
    • 2768749 - Termination Date excluded in calculation for Number of Months in Termination Rule

    Keywords

     onView, Calculated fields , transient fields, rule, custom field,Time, in, Job, Calculated, transient, Transient, Trigger onView Rules for HRIS Elements, rule, custom field , KBA , LOD-SF-EC-EMP , Employment Information (Employment Details) , How To

    Product

    SAP SuccessFactors Employee Central all versions