Bad table event onRecordDelete

Hi

My table event prevents the deletion of a record. But it shouldn’t.

If the only line of code is ‘return true’, the record can be deleted.
But my code is

if (utils.hasRecords(classes_successor_of_classes)) {
	classes_successor_of_classes.class_level_number = null;
	classes_successor_of_classes.class_period_fraction_name = null;
	classes_successor_of_classes.class_period_school_year = null;
	classes_successor_of_classes.class_sign = null;
}
	
return true;

Why does this prevent the deletion?

Regards

Hi Birgit,

Just a guess but perhaps you need to save the changes first before it can delete the records?

Hi Robert

Thank you for the idea. But it didn’t help.

Actually, I can delete the code inside the if statement and I still cannot delete. Or, I can omit the if clause and still cannot delete. Strange.

Regards

Any help?

Is anybody using this event successfully? Could you please post the code?

Thank you and regards

What does the exception property hold of the record that wasn’t deleted?

Are you sure that “classes_successor_of_classes” is a valid reference? What if you put a try/catch around it and output the exception to the log? Maybe that’ll bring up something usefull.

Paul

Birgit,

Do the logs show anything?

Rob

Thank you both for the help!

It was the relation. I’m sorry, thats a problem I should have solved myself.

In the context of the global method, the relation was unknown. It should be ‘record.relation’. The try and catch did show the error. I didn’t even think, an error could occur :) . And not be visible.

Thanks again and regards