OnInsert() EXIT?

Hello!

In this trigger, I cant find a way to skip an insert on a condition. I have other workarounds but it would be very nice[:)] to skip in the trigger.

/K

you could raise an error.

From help:
If there is an error in the C/AL code you enter into this trigger, the system does not insert the new record.

Thanx!

That is very true but some times it’s perhaps only the 4:th record out of 6 to be rejectet! Then what?

/K

Then I assume this is one of your workarounds: have a MyOnInsert(VAR External: boolean) function in the table with an additional parameter that gives you the information if it is called from the table or externally. Copy ALL functionality from the OnInsert trigger to this function. Call this function in the OnInsert() trigger with VAR External FALSE. If you would call MyRec.Insert(TRUE) externally, add the function call before with VAR External TRUE, handle inside the function OnMyInsert(), change VAR External to FALSE inside the function if necessary. Afterwards depending on VAR External call MyRec.Insert(FALSE) or do not call.

Thanx Joerg!

Yes, it locks a bit like one of my workarounds. I’ll try somthing simmular.

[:)]

/K