[closed] Associated Content Cannot be Deleted

I’m fairly sure the answer is “that’s the way it is”, but is there a way to ignore the message about associated content not being able to be deleted and just do so anyway? Is there something in the CFproperty that would disable that?

That’s right, the built-in file and image content types stop you from deleting records that are currently in-use / related to other content types. This is because if you delete that record then there will be some array or UUID properties somewhere that are referring to the object and you’ll break your referential integrity.

The “easiest” way to resolve it would be to find where the object is used, remove the relationship(s), then delete the object.

It would be possible to extend dmFile and/or dmImage into your project, then override the delete method using a copy of that method from types.cfc, but you could end up with the integrity issues I mention above so I wouldn’t really recommend it. Another possibility would be to improve the output so that instead of telling you the object can’t be removed, it could list the other objects that the item is related to.

Eh, not a big deal. The end user is just going to delete the main object first at this point and then remove the underlying associated content. I wanted to check and see that there’s no means to override the default.

Yeah, not an easy “configurable” one unfortunately, but still entirely possible if you want to override the delete method like I mentioned above.

You could even have it delete the object and all it’s relationships, but for real world usage you’d probably want to show some kind of confirmation (“This item is related to 5 objects, * list them *, are you sure you want to delete this item and all it’s relationships?”).

1 Like

Indeed. But since dude isn’t planning to put any financing into this, I’m going with the option that’s presently within his sphere of control ;).

1 Like

@justincarter: Would it be worth considering a core change to allow a custom message to be sent to the core delete method? Might be a workable trade off?

Note I have a vested interest in such a feature :slight_smile: Dominic just pointed me to this thread after asking for a change to the message for one of our projects Daemon is working on at the moment.

We can easily override the delete method to change the message if that’s all you need (or, we can change the behaviour as well), it’s just not a “configurable option” is all :slight_smile:

I think if we were improving core it would make sense to implement some kind of delete cascade / delete type, but it would need to function or be configurable at both a property and a component level. Needs a bit of planning.

This is the approach I took - I will see if can find which project I did it
on

do you have this?
https://farcry.jira.com/wiki/display/FCDEV60/Custom+Overview+Tab+-+Related+Content

I have attached my file