I have an object hierarchy and it's giving me some challenges in my event handlers when deleting objects.
When I try to delete a PARENT object, and it warns me that it will be deleting the child objects, I then receive an error:
CoContextMenu.cpp, 740, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CommandStore.cpp, 403, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MFShellCommands.cpp, 16914, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCommands.cpp, 317, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MFShellCommands.cpp, 849, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MFShellCommands.cpp, 5129, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MFShellCommands.cpp, 13009, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CoShellFolder.cpp, 3885, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CoShellFolder.cpp, 10123, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) VaultDocumentOperations.cpp, 961, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) VaultDocumentOperations.cpp, 1014, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) ThreadOutCaller.cpp, 67, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) ThreadOutCaller.cpp, 583, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) VaultMethodCallTasks.cpp, 883, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CoVaultMountingDocumentOperations.cpp, 1067, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) DocumentCache.cpp, 8326, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) DocumentCache.cpp, 20002, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) IRPCObjectOperations.generated.cpp, 4847, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) gRPCClient.cpp, 496, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) gRPCClient.cpp, 465, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) gRPCClient.cpp, 98, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) gRPC.generated.cpp, 15143, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCDocumentOperations.cpp, 6548, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCallInLoop.h, 521, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCDocumentOperationsHelper.cpp, 2789, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCDocumentOperationsHelperPrivate.cpp, 13416, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCObjectTypesHelper.cpp, 10618, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCDocumentOperationsHelper.cpp, 18813, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) RPCDocumentOperationsHelperPrivate.cpp, 17001, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 785, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 942, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 996, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 941, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 1145, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) SQLHelper.cpp, 7171, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) CachedDBSession.cpp, 1143, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCommand.h, 584, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCommand.h, 843, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCommand.h, 801, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) MCommand.h, 583, Error 50000, Level 11, State 1, Procedure -, Line 1, Message: Count mismatch SQL error. [2] (ERROR: 50000, SQLSTATE: 42000) (0x80040E14) (M-Files 23.4.12528.8 2023-04-27T13:37:47.457Z)
This error occurs if I delete the parent, but not if I first delete all child objects and THEN attempt to delete the parent. What I would like to do is to catch this in an event handler and use MFScriptCancel if the user is deleting the parent object and the parent has children.
I've tried to do this with a "BeforeDeleteObject" event handler looking for the parent object type, checking if the parent has children, and then cancelling execution.
Unfortunately it seems like when you delete a parent and it's children M-Files separately deletes the children first, so it's not possible for me to tell if the parent has children, as by the time it gets to that point the children must have already been deleted. It also doesn't appear to count as a recursive call, as I'm not able to tell that the action deleting the child is not the parent transaction when I try checking the current / parent / master transaction IDs.
Any help with this would be great!