Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedDelete module related data when module is deleted from pageDelete module related data when module is deleted from page
Previous
 
Next
New Post
1/24/2013 9:00 AM
 

Hi all,

I was wondering if it is possible to delete related data when a module is deleted from a page.

We store a list of displayed objects together with moduleId and tabId in a different table.
When a module is deleted from a page this data needs to be deleted too.

Is there a way to do this at least after the recycle bin is cleared? And if so how can I hook up this action and where?

Any help is kindly appreciated,
have a great day
Andy

 
New Post
1/24/2013 2:34 PM
 
Yes. That's done by creating a foreign key on the Modules table and setting the delete action to cascade. Take a look at any of the core module for an example.

Here's how it's done on core HTML module:

ALTER TABLE {databaseOwner}[{objectQualifier}HtmlText] WITH NOCHECK ADD CONSTRAINT [FK_{objectQualifier}HtmlText_{objectQualifier}Modules] FOREIGN KEY ([ModuleID]) REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) ON DELETE CASCADE NOT FOR REPLICATION

-----------------------------------------------------
This is added to your SQLDataProvider / SQL Script file.

Mandeep Singh
CEO - Mandeeps.com | Developing DotNetNuke Modules Since 2004
DNN Monitor | DotNetNuke Keep Alive Service
 
New Post
1/25/2013 2:26 AM
 

Thanks a lot for your help Mandeep,
while the constraint will be a good way to deal with most of the data which is related to a certain module (I already implemented your suggestion and it works like a charm) and perfectly plays along with the recycle bin I will have to deal with data that is not stored on the same server and is hosted in a different environment (MySql and MS SQL).
In this case the constraint will not allow me to manipulate data on different servers or fulfill certain tasks that might be related to the module.
I read a lot this night about this topic and it seems that there is no way to execute code upon the removal of a module from the recycle bin.

I came up with two possible solutions. One is to add an IActionable to be clicked before delete is clicked on the module, but this screwes the recycle bin option (module can not be restored). The other one is a scheduled task that checks if a module was removed and then executes whatever is necessary to clean up.

Do you have any other idea how to deal with this requirements?

Thanks a lot Mandeep for your help and have a great weekend,
best regards
Andy

 
New Post
1/25/2013 5:45 PM
 
Andy, you're right there is no way to execute code when a module is deleted (removed from recycle bin). You can pursue your idea of creating an action item (IActionable) and then executing your code followed by original dnn core delete code (you can refer to source code for this). The only issue with this is to create a procedure that the new delete action should be used instead of the default one and making sure your end users are following it.

Another thing I can suggest is to use SQL Triggers. You can execute compiled .NET code (CLR Stored Procedures). Simply create a trigger if the row is deleted from the Modules table. Hope that helps.

Mandeep Singh
CEO - Mandeeps.com | Developing DotNetNuke Modules Since 2004
DNN Monitor | DotNetNuke Keep Alive Service
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedDelete module related data when module is deleted from pageDelete module related data when module is deleted from page


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out