This discussion is archived
1 Reply Latest reply: Dec 11, 2012 1:48 AM by GopinathRamasamy RSS

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

977766 Newbie
Currently Being Moderated
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?
    GopinathRamasamy Journeyer
    Currently Being Moderated

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

    Hope this helps.

    Keep posting the updates / questions.

    Gopinath Ramasamy


  • Correct Answers - 10 points
  • Helpful Answers - 5 points