G’day all. I have some table, name isn’t important here. From OnInsert trigger of this table I’m calling external function, and I’m passing “Rec” variable to that function. In the body of the function I’m trying to initialize some local RecordRef-type variable using SETRANGE functions with primary key values from passed “Rec” variable. But in fact the record which I’m trying to initialize is not inserted yet, because I’m calling the function from OnInsert and record doesn’t exists in database fisically. It’s critical for my application to handle calls from OnInsert. I have a workaround - to make a lot of specific functions for every table, but I’d like to have common generic one. Maybe someone see another solutions? Any opinions are welcome.
I’m not proud of it, but I have once made a solution to this problem… I simple did like this: >OnInsert() >Insert; >MyFunctionThatRequiresItInserted(Rec); >Delete; // Gets inserted again after the OnInsert trigger I know it looks very strange, but I have not been able to find a situation where it doesn’t work exactly as is should.
In the body of the function I’m trying to initialize some local RecordRef-type variable using SETRANGE functions with primary key values from passed “Rec” variable.
Can’t you use the current Rec in which the Insert is fired as source for a RecRef Variable using GETTABLE()? What do you want to check with your filters ? Maybe we can find another solution?