This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Delete Relationship item OnDeleteRow

Yelena - Thursday, June 18, 2009 12:56 PM:

Hello,

I'de like to write a method that will delete the relationship item when relationship row is deleted.

Do anybody has an example that I can use.

Thank you,

Yelena

 



Andy - Thursday, June 18, 2009 2:10 PM:

Why not just make the relationship dependent?

Andy



Yelena - Friday, June 19, 2009 3:57 PM:

Andy,

Thank you for response. Could you please clarify?  Maybe I did not explain correctly what i am looking for.

I have two itemtypes item1 and item2

item1 has a relationship  to  item2. I want the functionality which will delete the correspondent instance of  item2 when  relationship instance is deleted from the item1.

Thanks again for your help

Yelena



SamsAn - Saturday, June 20, 2009 12:35 PM:

Options:

1. Make IsDependent=1 for item2 ItemType (i believe this was meant by Andy).

2. Assign OnBeforeDelete and OnAfterDelete methods for item1_item2 is_relationship itemtype. OnBeforeDelete should put the relationship related_id value to session. OnAfterDelete method should take from session the related_ids to remove and remove item2 instnaces.


SamsAn.
Original Mind Any Level Innovator Solutions Free-Lancer, http://sites.google.com/site/caraacc



Yelena - Wednesday, June 24, 2009 1:50 PM:

Thanks for your help,

Yelena



ksalvitelli - Friday, June 4, 2010 4:53 PM:

SamsAn,

You mention 'value to session'. How do you do that. I have set up the onBeforeDelete, now what do I do with the result? How do I pass the parameter to the OnAfterDelete Method?

Regards,

 

Kenneth



zapping - Wednesday, June 16, 2010 6:41 AM:

Use this to set your session on the OnBeforeDelete method event. Can be a string or object like the Item itself:
CCO.Session["TheItemDeleted"] = deletedItem;

Use this to retrieve it from session on the OnAfterDelete method event
Item prevItem = (Item)CCO.Session["TheItemDeleted"]

Use this to remove it from session:
CCO.Session.Remove("TheItemDeleted");