Hello there, (I'm using NAV 2016 (9.00.47838))
I got a strange problem by using xRec in OnModify:
I want to do something only after OnModify if a boolean field is changed: Ensure that only one record is the Default record.
IF Rec.Default AND NOT xRec.Default THEN BEGIN
The problem is: Sometimes are Rec and xRec equal!
Yes, I know that similar questions are spreaded in the www.
Yes I know that the behaviour is different between internal call and external call and GUI call. And normally GUI call should work!
In my case there is only page interaction: Sometimes working, sometimes not working. > Changing behaviour without changing objects!
A simple table:
Only two fields:
FIELDS
{
{ 1 ; ;Code ;Code10 }
{ 2 ; ;Default ;Boolean }
}
KEYS
{
{ ;Code ;Clustered=Yes }
}
Code only in OnModify:
OnModify=VAR
TestSKM@50000 : Record 50202;
BEGIN
IF Rec.Default AND NOT xRec.Default THEN BEGIN
TestSKM.SETFILTER(Code, '<>%1', Code);
TestSKM.SETRANGE(Default, TRUE);
IF TestSKM.FINDSET(TRUE) THEN
REPEAT
TestSKM.VALIDATE(Default, FALSE);
TestSKM.MODIFY;
UNTIL TestSKM.NEXT = 0;
END;
END;
And a simple list page created by the wizzard.
So I filled the list with the codes '1', '2', ..., '7'
When setting the Default in a record after leaving the record (MODIFY) all other records should be set to Default = FALSE.
I cannot find a rule. Sometimes it works, sometimes it doesn't work.
Sometimes setting Default from top record to bottom record works.
Sometimes Setting Default from bottom record to top record leaves all record Default = TRUE.
Is there any Explanation?
With kind regards
s_keim