I Have a table with
Item no.
Variant
Code
Page No.
Default Page
For every Item No.,Variant,Code it can only have 1 default. What code would I have to add to permit only one
?
I Have a table with
Item no.
Variant
Code
Page No.
Default Page
For every Item No.,Variant,Code it can only have 1 default. What code would I have to add to permit only one
?
Hi ,is Page No. Part of your key?
if so then its simple , just add the 4 fields to your key.
Otherwise need to write code for checking duplicate combinations with same Default Page for the Default Page validation trigger.
g.
I can not do a key cause there can only be one true, but can be multiple false default page.
does this code seem correct for this? is there a better way of doing this?
IF “Default Page” THEN BEGIN
RESET;
SETFILTER(“Item No.”,“Item No.”);
SETFILTER(Variant,Variant);
SETFILTER(Code,Code);
SETFILTER(“Default Page”,‘TRUE’);
DefaultCount := COUNT;
IF DefaultCount >= 1 THEN
ERROR(Text001,“Item No.”,Variant,Code);
RESET;
END;
I did something similar on the Ship-to Table. Only 1 address can be the “Primary Account”.
So I added a boolean field to the ship-to table called “Primary Account”
I added this code to the Ship-to Table
(Var) ShipToAddress - Record - Ship-To Address
OnModify()
IF “Primary Account” THEN BEGIN
ShipToAddress.RESET;
ShipToAddress.SETRANGE(“Customer No.”,“Customer No.”);
ShipToAddress.SETRANGE(“Primary Account”,TRUE);
IF ShipToAddress.FIND(’-’) THEN
IF (ShipToAddress.Code <> Code) OR
(ShipToAddress.NEXT <> 0)
THEN
ERROR(‘Only one primary ship-to account per customer!’);
END;
ultimately decided to with:
Default Page - OnValidate()
IF “Default Page” THEN
LookForDuplicate;
Then Created a new Global
LookForDuplicate()
ItemCatalogPage.SETRANGE(“Item No.”,“Item No.”);
ItemCatalogPage.SETRANGE(Varaint,Varaint);
ItemCatalogPage.SETRANGE(Code,Code);
ItemCatalogPage.SETRANGE(“Default Page”,TRUE);
IF ItemCatalogPage.FINDFIRST THEN
ERROR(Text001,FIELDCAPTION(“Item No.”),“Item No.”,FIELDCAPTION(Variant),Variant,FIELDCAPTION(Code),Code);