Hi Team,
I'm creating a mobile application. I'm basically trying to display different prices from static entity via dropdown box depending upon the duration of that service. Like this:-
I've multiple services displaying different prices depending upon duration.
The problem I'm facing is at the time of calculation total price. I'll have to apply multiple if's and else's in for calculating the price for different scenarios. Is there a simpler solution?
For more information I've attached .oml file.
Regards
Sahil
Hello Sahil,
I have a suggestion for your concern which will definitely reduce your conditions and probably one condition will be enough but this will require lots of changes in your current price calculation way.
This solution require below steps:
1. Need to add extra attribute in your static entities for which you want to calculate price.
eg. : In Duration entity, you can add DuraPrice attribute with data type currency and set specific price for each item ->
Similarly for Temperature :
2. Now while calculating price, you will have to use these added attribute values and you will be able to calculate price in one go. Like below expression(just eg):
TotalPrice = (SteamPrice* DuraPrice + SteamPrice*TempPrice ) +(SaunaPrice* DuraPrice + SaunaPrice*TempPrice )
Hope it helps!
Thanks,
Sanjay
Sanjay Kumar Sahu wrote:
Thank you Sanjay for your valuable advice. It worked.
I think I would create a structure with the different segments that together form the price. And then I would change certain properties of that structure whenever a widget is changed (via the OnChange action). That way I would only need to create one Sum action that sums all properties but let the different widgets decide what the price is for their respective component.
I hope this make sense otherwise I can make a demo to clarify it more.
Greetings,
Vincent
Vincent Koning wrote:
Hi Vincent,
Thank you for replying. A demo would really be appreciated.
Hi Sahil,
I did some code changes in the .oml file, please validate the Duration Dropdown (Steam and Sauna) OnChange action flow -> switch case condition and the mapped value in the assignment nodes based on your business.
Please refer the attached .oml file
Regards,
Benjith Sam
Benjith Sam wrote:
Hi Benjith,
You simplified my existing if's and else's & it was really great to see that we can perform such a functionality in a much simpler and short way but my main problem was to calculate the total price. What you've done is stored the SaunaId and SteamId in the local variable depending upon the changes done to drop down menu. I've to now calculate total price.
For example if the customer wants to avail only Sauna service for duration 20 minutes and Steam service for duration of 30 minutes. I'll have to create multiple if's and else's condition for each of the case. In my scenario total cases would be 27 I guess following are the few examples:-
Cusomter didn't select Steam Service + customer selected sauna service for 20 mins duration
Cusomter didn't select Steam Service + customer selected sauna service for 30 mins duration
Cusomter didn't select Steam Service + customer selected sauna service for 30 + mins duration
Customer selected Steam service for 20 mins duration+ customer didn't select Sauna service
Customer selected Steam service for 30 mins duration+ customer didn't select Sauna service
& so on. Each time I'll have to apply if & else or switch case condition to check what is the respective id of SteamId & SaunaId variable & depending upon that I'll have to do the calculation. I wanted a shorter & simpler way to do it.
Glad, I could help :)