How to use Calculated Attribute?

0
I am working in an app called Hospital management systems, their is one scenario where I want to display number of available beds and when I assigned one bed to a patient then total number of beds should be reduce by one. How can I achieve this using Calculated attribute and what will be logic in the microflow. Please help. Thank you!
asked
2 answers
2

Be sure to check if you actually want to use a calculated attribute or not. There's some documentation about that here:

 

Performance Best Practices

 

You can either do this with a calculated attribute, or by updating an attribute each time you assign a bed.

I'm going to make some assumptions about your domain model since you did not include it in your question.

 

If you were to make the AvailableBeds a calculated attribute, you could make a flow that looks something like this:

 

Edit: changed the order of my answer to highlight the importance of deciding whether or not you want to use a calculated attribute

 

answered
0

Hi 

I wouldn’t use a calculated attribute as each time you retrieve this entity it will recalculate. The next easiest thing would be to use a after commit Event Handler that calculates the required values. 

Regards,

Patrick

answered