How to add chosen entity attributes from Combo Box together

How to add chosen entity attributes from Combo Box together

  

Hello,

I have a simple site containing 4 combo boxes with 4 options each. The coupled entities consist of an ItemName and a Price, only showing the ItemNames in the combo box. I have local variables holding the identifiers of the chosen entities. 

I have an Ifcontainer below this, which has to show the total sum of the items chosen, but I can't figure out the expression I should use. In other words: how do I get from the identifiers to the price to add them all together? 

Thanks in advance!

Solution

Hi Maikel,

I hope you have figured this yourself.

If that isn't the case I did a quick example based on your description. Is this what you were looking for?

https://joaoheleno.outsystemscloud.com/Combos4Maikel/Entry1.aspx

You can show the Items and Price at the same time... but I won't tell you right away :) Can you figure it by yourself?

Please find the above code attached to this reply.

I can see you're new here. Let us know if you need help and sorry for the late reply.

Cheers,

João Heleno


Solution

Thank you for the reply João Heleno. I did figure it out (I simply had to use a Get using the variables I already gathered on the page to get the price and add them together. 

You're example looks similar. If I understand it correctly, you can see the individual prices if you just select one item and leave the other blank ('-') right? Looking at the code you also use another local variable to calculate the total. In my solution I use an expression for this:

SyntaxEditor Code Snippet

GetElement1(Var1).Element1.Price + GetElement2(Var2).Element2.Price...


What do you recommend as a best practice, use an expression or another local variable which is simply called upon in the expression? Or doesn't it make a difference?


Thanks again in advance,

Maikel

To display the name and price at the same time use and advanced query that returns the id of the product and a string that is the result of the concatenation of the label and price, so that your combo shows all the info at once.