Actually i created a user repository item using handleCreate() method of ProfileFormHandler e.g xyz and contactInfo RepositoryItem e.g.,abc .the user xyz has a property homeAddress which is a one-one item type relationship and points to contactInfo repositoryitem(abc).can anyone please help me by providing the solution how to delete the contactinfo item(abc) without deleting the user item(xyz).
1. Create a handleRemoveHomeAddress method in your form handler.
2. The logic of the method is
- get TransactionManager and TransactionDemarcation
- begin a transaction by transactionDemarcation.begin
- get the commercepropertymanager by calling getProfileTools.getProfileManager()
- set the homeAddress property of the user to null using the below code (This is to remove the reference)
- remove the contactInfo Item from the repository
3. catch any exception and handle the transaction accordingly.