Answered

how to get distinct value using CEntityManager.GetEntity?

i have a requirement in which i have to retrieve distinct values from a collection using CEntityManager.GetEntity

when i am trying distinct function to extract distinct values using below line code i am getting error. error snapshot is attached.

CEntityManager.GetEntity("<distinct-values(CrewList)>").GetEntityList("Vessel", vessel, "", "");

Comments (7)

photo
1

Dear Rahul,

You are using in a wrong way this function. You should get the collection and then apply the function. Distinct-values: Returns a filtered collection with no repeated values of an attribute. It is necessary to indicate the attribute for which the values will not be repeated.

Example: We need to know how many different phone numbers have been dialed to contact the customer

  1. DiffPhone = <distinct-values(ClaimsAndComplaints.Calls.TelephoneNumber)>;
  2. <ClaimsAndComplaints.DiffPhoneNumbers> = DiffPhone.size();




For further information: http://help.bizagi.com/bpm-suite/en/index.html?xpath_advanced_functions_examp.htm


Regards

photo
1

My Problem is my collection is intially blank because it is on start task' form. but i do have values in db. i am extracting those values from db using this function

CEntityManager.GetEntity("<distinct-values(CrewList)>").GetEntityList("Vessel", vessel, "", "");

based on some filter then i am again setting all the values in the collection. Because of this situation i cant use what u said. any other way is there to do it? please tell it will be helpfull.

photo
1

Dear Rahul,

Thank you for your feedback. The main problem is that you are using incorrectly this function. You need to follow this sintaxis:

  1. CEntityManager.GetEntity("Entity").GetEntityList("Attribute","Filter","Search","Order");

For further information: http://help.bizagi.com/bpm-suite/en/index.html?access_entities_not_related_to.htm

After this, you will get a collection to which you can apply distinct-values function.

Regards

photo
1

Hi Rahul,

I want to use the distinct values function to filter my collection 'colQuotes' where different 'Contacts' can send a quote. Now some contact quote multiple times, but I want to have a list of single contacts.

I used your example above to set up my function, but I don't know what kind of object the 'DiffPhoneNumbers' is in this part of your function: <ClaimsAndComplaints.DiffPhoneNumbers> = DiffPhone.size();

Is that an attribute of the entity ClaimsAndComplaints? And what kind of attribute? A boolean?

My function looks like this till now:

var noDoubleCarriers = <distinct-values(subSortContacts.colQuotes.Contact.BizUserId.userName)>;

<subSortContacts.DiffCariers = noDoubleCarriers.size();

But I am not sure if the 'DiffCarriers' part is right, do I need to add it as an attribute to the entity 'subSortContacts'?

Thank you in advance

Bo

photo
1

Hi Bizagi,

I had posted a comment on this topics last Friday, but I can't find it anymore, does it still needed to be approved?

Bo

photo
1

Best Juan,

Could you please have a look at my question above?

Thank you in advance

Bo

photo
1

Dear Bo,

Analysing your comment, I met that you should use Tracing in order to check each step of your rule. You can follow this article to get further information: http://help.bizagi.com/bpm-suite/en/index.html?validating_my_business_r.htm

Regarding the posted comment:

  1. <ClaimsAndComplaints.DiffPhoneNumbers> = DiffPhone.size();

DiffPhoneNumbers is a number and DiffPhone.size(); is a function that returns the size of the collection.

So, if your collection has 5 registers for example, and you apply the distinct-value function, your new size will be 3 registers.

I can see that you are using correctly the function. Implement tracing to be sure of it.

Best Regards