How to set up a decrease in an attribute value?

0
I have an electric car charging reservation app and I am building a microflow so that once the user chooses the charger they want it checks if the capacity is above 0 and if it is available it lowers the capacity of the charger(by capacity I mean number of available chargers) and does this for a set time, 1, 2 or three hours.   So far I have this as my microflow, the availability(capacity) should be lowered by one it is an attribute of my ChargingStation entity, I have already created a microflow where I can create new chargers and set up their availability.    
asked
1 answers
0

Hello Gal Verlic,

 

What you are going to need is an entity (persistent or non persistent, in your case I think persistent) that summarizes the availability of the stations., so maybe you can call it it AvailabilitySummary or GeneralInformation. 

 

After you create this entity with at least one attribute of type integer that represents the available stations, you can do several things to update this attribute most common options are the following two:

 

Option 1. 

You can make an event handler on the entity that calculates the availability of stations everytime you commit a station object, you do this after the status of a station changes.

 

Option 2.

Instead of a event handler you just create a microflow that you use as a submicroflow and you use this sub microflow after the status of a station changes.

 

Hope this helps,

 

Good luck!

 

 

answered