addressing and attribute in a list

1
0
-1

HI there,

I have a business object prescription, and a list of items in it (prescriptionitems is another business model ) with composition relationship.

prescriptionitems has an boolean attribute (coveredByInsurance). I want to check all of the coveredByInsurance for one prescription to check if they are all 0 or not?

How I can write a script in condition part of a XOR gateways

Thank you

1 answer

1
0
-1
This one is the BEST answer!

hello,

On the branch of the gateway, i imagine you can use a condition expression close to this one:

import com.company.model.Prescription
import com.company.model.PrescriptionDAO

Prescription prescription = PrescriptionDAO.findByPersistenceId(prescriptionId);

for (item in prescription.getItems()) {
if(!item.coveredByInsurance){
return false;
}
}

return true;

a smarter way to do this would be to create a Custom query "countNoneCoveredByInsuranceItems" instead of the [FOR loop + findByPersistenceId]

hope this helps,

Julien.

Comments

Submitted by snabavian_1416306 on Mon, 04/06/2020 - 16:50

Thank you very much.

Submitted by julien.mege on Mon, 04/06/2020 - 19:12

cool, if you solve your use case thanks to this answer, can you Validate the answer, to make it visible for the community?

thx

Notifications