Answered

Add existing entities to a collection

Hello!

How do you add an existing entity record to an entity collection?

An example:

We have an Invoice master entity, which is a process entity in process A. There's another master entity called PreparedInvoices. This is a process entity in process B. PreparedInvoices has a 1 to many relationship via collection to the Invoices entity, so 1 PreparedInvoices may contain many Invoices. So at this point process A created a lot of Invoices, but we have no PreparedInvoices so far . Now, I would like to show some of the Invoices in process B in a table. The idea is to have the PreparedInvoices entity and dynamically add the Invoices that I want (based on some filters) to the collection to the PreparedInvoices. So, how do you do that without manually copying each attribute to a new collection item ? And yes, it would be nice that if the Invoice object gets modified, it is reflected in the Invoice collection of the PreparedInvoices. So no copy, but reference.

Thank you in advance!

Best Answer
photo

Dear Zoltán,

We think that you can clone or copy existing records using expressions with some functions:

  • Add items (records) to a collection

In order to create items (records) in a collection using a business rule, Bizagi offers a function called newCollectionItem. Visualize your collection as a table. Creating a new item is comparable to adding a new row to a table. First you need to create the new row and then set the desired values for each column. The new record (row) is created using the newCollectionItem function. This function is available in the Functions list of the Collections category.For further information: http://help.bizagi.com/bpmsuite/en/index.html?add_and_remove_relationships.htm

  • Attach items (records) to a collection

Attaching an item of a collection is connecting an existing record from a table to another table, within the same case, sharing the information.The item (record) will then belong to both tables, not duplicated, just shared. That is, when information of this record is updated, changes will be reflected in both tables. If you need to move an item from one collection to another, you can do so by attaching the item to the new collection and detaching from the old collection. You don't need to duplicate and re-create.For further information:http://help.bizagi.com/bpmsuite/en/index.html?attach_items_records_to_a_coll.htm

Regards

Comments (8)

photo
0

Dear Zoltán,

We think that you can clone or copy existing records using expressions with some functions:

  • Add items (records) to a collection

In order to create items (records) in a collection using a business rule, Bizagi offers a function called newCollectionItem. Visualize your collection as a table. Creating a new item is comparable to adding a new row to a table. First you need to create the new row and then set the desired values for each column. The new record (row) is created using the newCollectionItem function. This function is available in the Functions list of the Collections category.For further information: http://help.bizagi.com/bpmsuite/en/index.html?add_and_remove_relationships.htm

  • Attach items (records) to a collection

Attaching an item of a collection is connecting an existing record from a table to another table, within the same case, sharing the information.The item (record) will then belong to both tables, not duplicated, just shared. That is, when information of this record is updated, changes will be reflected in both tables. If you need to move an item from one collection to another, you can do so by attaching the item to the new collection and detaching from the old collection. You don't need to duplicate and re-create.For further information:http://help.bizagi.com/bpmsuite/en/index.html?attach_items_records_to_a_coll.htm

Regards

photo
0

Thanks Juan!

I am aware of these solutions.

The problem with the first approach (Add items with newCollectionItem) is that it's not programmer friendly... writing a lot of Newrecord.setXPath("Column",Value) but the biggest problem is that it is a copy. So when the original record (entity) gets updated the copied one will not reflect those changes. So it's a no go.

The second approach would be nice if it would not be restricted to the same case. But as I said, the case is not the same. One process creates the single entities (Invoice), and another process has to process them in a batch.

The BPMN "design pattern" I try to achieve here is best described here: http://mainthing.ru/item/150/

So one process creates entities, and another batch and scheduled process does something with those entities and when finished with an item it communicates back to the first process to move it forward.

So, any idea how to share existing entities between processes? I know one: using external data source to persist the entities and read them back in the batch process... but any better solution you may have?

Thanks!

photo
0

Dear Zoltán,

In order to access to entities, you have two choices using expression. Again, the second point is the best way for you but we want to share both in order to know the different ways to do it:

  • Data Access through XPath

All business rules use XPath navigation to help the user traverse the data model in an intuitive way. The XPath standard is a easy-to-use language for finding information in an XML document and is helpful in carrying out complex tasks. Bizagi incorporated this concept into its language, enabling users to easily navigate and use the data model to accomplish different tasks. XPath as a navigation tool enables users to navigate the data model accessing attributes and relationships. The 'location path' of the desired attribute in the data model is always written between diamond brackets:< xpath route >For further information: http://help.bizagi.com/bpmsuite/en/index.html?undestanding_xpaths.htm

  • Access entities not related to the data model

It is a common requirement to access Parameter and System entities that are not related to the data model, in order to extract information for use in XPath expressions.In such cases, where the entities cannot be accessed directly through XPath navigation, the EntityManager functions are employed. The information returned by EntityManager is handled as a collection of items. You will then need to iterate over the collection to access specific information (i.e. the item values).For further information: http://help.bizagi.com/bpmsuite/en/index.html?access_entities_not_related_to.htm

Regards

photo
0

Thanks, I will give the 2nd approach a try.

Regards,

Zoltán

photo
0

Dear Juan!

I am able to query the Master Entity that I want and I am able to access it's attributes. Am I right if I say that the only possible solution to build a list (collection) of master entities is to use the newCollectionItem function and setXPath function to copy all the attributes to a new entity record?

Any idea on how to show a user a list of entities in a table given that the single entities are created using a different process? I am unable to overcome this problem.

Regards,

Zoltan

photo
0

Dear Zoltán,

There is no a way to do what you need. If you mind, you can share an idea explaining you point and all users can vote to be developed in a future release.

Best Regards

photo
1

Hello Zoltán,

I know you posted the issue one year ago. Nevertheless, I would like to contact you. I am Phd working in the area of business process technology. In our research group, we have developed an approach to incorporate batch processing requirements in business processes. I would happy to explain you our idea and I would be very interested what special requirements your use case has. If you are interested in sharing ideas, feel free to contact me: luise.pufahl@hpi.de

Cheers, Luise

photo
1

Dear Luise,

We invite you to use our feedback platform on the ideas space to post your request.

This platform will allow you to share your ideas so that the whole Bizagi BPM Suite community can vote and discuss them. We want to make sure we solve the needs of our clients, so that we can add the features you consider most important.

Regards