Visualize your collection as a table. Deleting an item is removing a row from a table.
Records in a collection can be deleted or detached.
When you delete a record it will be removed form the collection and from the database.
When you detach a record it will be removed from the collection but it will stay in the database.
When a record is shared by two or more collections, we recommend detaching instead of removing.
If you definitely want to delete an item (or record) you have three options:
•Delete all collection items: deletion of all the items (records) of a collection is done using the deleteAllCollectionItems function.
You only need to specify the Xpath to the collection and all the records will be deleted.
•Delete some collection items: deletion some items (one or more records) of a collection is done using the deleteCollectionItems function.
You need to specify the Xpath to the collection and the Xpath filtering the items you want to delete.
•Delete ONE collection item: deletion of ONE item (record) of a collection is done using the deleteCollectionItem function.
You need to specify the Xpath to the collection and the Xpath filtering the single item you want to delete. If more than one Xpath is found the function will present an error to the end user.
The functions are found in the Collection category.
The syntax of the functions is as follows:
Let's take a Projects Administration process to illustrate how elements from a collection are deleted. Suppose you have tables of the project's activities and you wish to remove some activities according to business conditions.
In order to do this follow the next steps:
1. In the fourth step of the Bizagi Process Wizard (Business Rules), select Activity Actions.
Click the Task in which the activities will be deleted and create an On Enter Expression.
2. Create the expression and enter the following code to remove the relation:
Click OK to save the changes.
Below you will find the different ways that elements can be removed depending on the business requirement.
if(<count(ProjectAdministration.Activities[Completed = true])>==1)
Me.deleteCollectionItem("ProjectAdministration.Activities", <ProjectAdministration.Activities[Completed = true]> );
Removes the only completed activity in the collection, and deletes this record from the data base.
Me.deleteCollectionItems("ProjectAdministration.Activities", <ProjectAdministration.Activities[Completed = true]>);
Removes all completed activities from the relationship and deletes these records from the data base.
Removes all elements from the relationship and also from the data base.