addressing and attribute in a list

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

 

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.

 

 

Thank you very much.

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

thx