I have a simple function
which applies a change to a field in the sales line to other sales lines using RECORDREF and FIELDREF.
ChangeSublineField(NewRec : Record "Sales Line";FieldNo : Integer)
SetTargetRange(UpdateRec,NewRec);
RecRefNewRec.GETTABLE(NewRec);
FieldRefNewRec := RecRefNewRec.FIELD(FieldNo);
IF UpdateRec.FINDSET THEN REPEAT
RecRefUpdateRec.GETTABLE(UpdateRec);
FieldRefUpdateRec := RecRefUpdateRec.FIELD(FieldNo);
FieldRefUpdateRec.VALIDATE(FieldRefNewRec.VALUE);
// RecRefUpdateRec.MODIFY(TRUE);
RecRefUpdateRec.SETTABLE(UpdateRec);
UpdateRec.MODIFY(TRUE);
UNTIL UpdateRec.NEXT = 0;
In the OnModify trigger of Sales Line there is code which compares Rec values with xRec values in order to notice a change.
When updating through my function no changes are detected and through debugging I found out that Rec and xRec are the same (both with the updated value).
It makes no difference [-X if I modify through
RecRefUpdateRec.MODIFY(TRUE) or through
UpdateRec.MODIFY(TRUE).
I can add the code from the OnModify trigger to the function but then every time someone changes the code in the OnModify trigger he or she must do this also in this function. This mean more documentation, etc., etc.
Does anyone has a solution for this problem.
I'm developing in 5.0, is it a bug? :bug:
Thanks,
Robert
Comments
In you situation:
Are you sure NewRec and others are defined as var?
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I never knew this, so this could have some serious consequences.
I think :-k we have to move some code to field validation or update functions , like UpdateUnitPrice or UpdateDates.
In your program, you can run this function yourself with an old version of the record and the version on which you are working. So you need to variables to do this.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Correct, and onmodify from header to lines (salesline, etc.) don't always work.