How to write logic to avoid creating multiple object for same employee for same data

0
Hi all, I am calculating employeed incentive based on their year completion and same microflow added to grid so whenever user load the page he can see the employee details along with years completion and its incentive amount. For calculation purpose I have used non-persistable entity. But now issue is for example last year I got 500 Euros incentive this year I will get 600 euros. This year it will show only 600 euros detail but what about the last year data that all vanish out.  So I want to also store the past data. I have created entity and simply created the object but every time page loaded new objects get created and for one employee there are multiple object. Please provide me a solution so I can store the employees past details without creating same object multiple time.  Thanks all
asked
1 answers
0

Hi Priyanka,

 

As Ganesh has suggested, you need some identifier on your incentive object so that you can decide in your microflow whether or not you need to create a new object or if a relevant object is already in the database.

For example, it sounds like employee incentives are on a per year basis so you could create a year attribute on the incentive object.  Then, in your microflow, you can check if there is an incentive object for the current year and if not, only then will you create a new incentive object for the current year.  On your page, you can choose to display only the current year incentive object or you can display a list of incentive objects sorted by year if you wish to see the previous years as well.

This all requires that your association is a 1-many association so that multiple incentives can be associated to your employee object.

Hope this helps get you going in the right direction,

Danny

answered