0
votes

Using appmaker & Google Cloud SQL -

I am trying to build a page that spits out whether information on various insurance policies meets minimum dollar requirements. I wasn't sure how to change the display text based on the result of a comparison, so I created two labels, one that says "Valid" and one that says "Does not meet minimum amounts", and am setting the visibility based on a binding expression. Basically, when I compare valueX with valueY, if X >= Y, then it displays the valid label, and if X < Y, it displays the other label. This appears to work just fine.

The data for the left variable is in the inherited datasource. The data for the right-side of the equation is in a separate datasource, based on a certain primary key. My problem is that I don't know how to specify what primary key to use in the binding expression, if that makes any sense. So for example, I am trying to compare the field AutoPolicyAmountLineOne from the inherited datasource (We'll call it ExampleA) with the field "ContractMinimumLineOne" from the datasource InsuranceTypes. InsuranceTypes has different insurances, #id 1 thru 4, (Auto is #2) - so I think I want to compare AutoPolicyAmountLineOne with InsuranceType.ContractMinimumLineOne where id should be set to 2. But I don't know how to use the id in the binding expression? What I have -

For the "Invalid Label" - Set the visible binding to

[email protected] < @models.InsuranceTypes.datasource.InsuranceTypes.item.ContractMinimumLineOne

But this only compares AutoPolicyAmountLineOne with the ContractMinimumLineOne for the first insurance type in InsuranceType. How do I specify which insurance id I want to use, so that I can access insurance types 2, 3, and 4?

(I am still new at appmaker, feel free to ELI5!!)

Thank you!

1

1 Answers

0
votes

Do you have relation between those to models InsurancePolicy <-> InsuranceTypes? If you don't I would recommend to add it (one InsuranceType to many InsurancePolicy). Having that your binding will look similar to this:

@datasource.item.AutoPolicyAmountLineOne < @datasource.item.InsuranceType.ContractMinimumLineOne

And don't forget to use prefetch to improve page's loading times and responsiveness.

Bonus

you can manage label's text using smth like this:

@datasource.item.AutoPolicyAmountLineOne <
@datasource.item.InsuranceType.ContractMinimumLineOne ?
'Invalid' : 'Valid'