Delete Relationship item OnDeleteRow

rated by 0 users
This post has 6 Replies | 1 Follower

Top 50 Contributor
Posts 36
Points 425
Yelena Posted: Thu, Jun 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

 

Yelena
Top 50 Contributor
Posts 28
Points 195
Andy replied on Thu, Jun 18 2009 2:10 PM

Why not just make the relationship dependent?

Andy

"I know this stuff like the back of my hand. Hey, where'd that mole come from?"
  • | Post Points: 20
Top 50 Contributor
Posts 36
Points 425
Yelena replied on Fri, Jun 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

Yelena
Top 10 Contributor
Posts 178
Points 1,240
SamsAn replied on Sat, Jun 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

  • | Post Points: 35
Top 50 Contributor
Posts 36
Points 425
Yelena replied on Wed, Jun 24 2009 1:50 PM

Thanks for your help,

Yelena

Yelena
  • | Post Points: 5
Not Ranked
Posts 1
Points 20

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

  • | Post Points: 20
Top 50 Contributor
Posts 29
Points 235
zapping replied on Wed, Jun 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");

  • | Post Points: 5
Page 1 of 1 (7 items) | RSS