1 Reply Latest reply: Dec 11, 2012 3:48 AM by Gopinath Ramasamy RSS

    how to delete a contact info repository item from profile repository item?

    977766
      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).

      Thank You!!!
        • 1. Re: how to delete a contact info repository item from profile repository item?
          Gopinath Ramasamy
          Hi,

          Please try the below logic.

          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)
          getProfile.setPropertyValue(getCommercePropertyManager()
                                        .getHomeAddressPropertyName(), null);
          - remove the contactInfo Item from the repository
          profileRepository.removeItem(addressId, getCommercePropertyManager()
                                   .getContactInfoItemDescriptorName());
          3. catch any exception and handle the transaction accordingly.

          Hope this helps.

          Keep posting the updates / questions.

          Thanks,
          Gopinath Ramasamy