Answered

count records in a collection

How can I count the records in an unrelated entity (Meters table) that match certain criteria. Then compare the count with another fixed number. If count is greater than the fixed number it must throw a validation error. I have been playing around all day, but not working. What am I doing wrong? I dont need to create a new collection or array of values, just check the count. Thank you.

Comments (2)

photo
1

Dear Ernie,

To access to a entity that is not related to the process, you require to follow this article: http://help.bizagi.com/bpm-suite/en/index.html?access_entities_not_related_to.htm

For example:

  1. //Evaluate if the collection has items

    if(<count(Request.Applicant.ApplicantMedicalTests)> == 0)

    {

  2. //Use the entity-list function to get all the Tests to be added to the collection. Filter the records by the required status .

    RequiredTest = Me.getXPath("entity-list('MedicalTest','Required = true')");

    //Iterate the variable in which the Tests are stored.

    for(var Counter=0; Counter < RequiredTest.size(); Counter++)

    {

    //Add each Test to the collection.

    NewTest=Me.newCollectionItem("Request.Applicant.ApplicantMedicalTests");

    NewTest.setXPath("MedicalTest",RequiredTest[Counter].getXPath("Id"));

    NewTest.setXPath("Delivered",RequiredTest[Counter].getXPath("Required"));

    }

  3. }

To know the number of register of a non related entity, you can use: RequiredTest.size().

To send validation messages to end users, you can use this: http://help.bizagi.com/bpm-suite/en/index.html?data_validation.htm

Best Regards

photo
1

Dear Ernie,

To access to a entity that is not related to the process, you require to follow this article: http://help.bizagi.com/bpm-suite/en/index.html?access_entities_not_related_to.htm

For example:

  1. //Evaluate if the collection has items

    if(<count(Request.Applicant.ApplicantMedicalTests)> == 0)

    {

  2. //Use the entity-list function to get all the Tests to be added to the collection. Filter the records by the required status .

    RequiredTest = Me.getXPath("entity-list('MedicalTest','Required = true')");

    //Iterate the variable in which the Tests are stored.

    for(var Counter=0; Counter < RequiredTest.size(); Counter++)

    {

    //Add each Test to the collection.

    NewTest=Me.newCollectionItem("Request.Applicant.ApplicantMedicalTests");

    NewTest.setXPath("MedicalTest",RequiredTest[Counter].getXPath("Id"));

    NewTest.setXPath("Delivered",RequiredTest[Counter].getXPath("Required"));

    }

  3. }

To know the number of register of a non related entity, you can use: RequiredTest.size().

To send validation messages to end users, you can use this: http://help.bizagi.com/bpm-suite/en/index.html?data_validation.htm

Best Regards