Spring 2018 release introduced many new features. Common Data Service for Apps can now have server-side logic and calculation defined at entity level for data quality and consistency. Which means logic will be applied once at data level instead of individual application level. These new capabilities include:
In this blog we will see how to benefit from Calculated and Rollup Fields. Let’s first understand what Calculated and Rollup fields are.
Create Calculated Field:
In Part 2, we created Company Product entity with field “Expiration Date” for a product. Using this field, we will create a new calculated field “Expired Since” which will calculate and display number of days since a product is expired.
Note – Option to add calculated or rollup field will be disabled for a field while creating entity. Save your entity first and then create calculated or rollup field.
For “Expired Since” it looks like below:
Create Rollup Field:
In Part 1, we create Company entity which is parent to Company Product entity. We will create a new Rollup field in Company field which will aggregate and shows number of products each company owns.
Note: Rollup field is created on parent entity to aggregate value of child entities.
Note: You will see warning message at bottom of this dialog which means once rollup field is created, it takes 12 hours for job to start and perform calculation. Please refer my blog for more details on how to update job to run immediately instead of waiting for 12 hours.
Once you are done with creation of Calculated and Rollup fields, you can add them to views and forms. Follow below steps to add fields on views:
Select your App from apps list (refer Part 3 on how to create app) and click Play. In case new fields not visible in views, refresh your page or edit & publish your app once