I have an API page for Ship-to adress (Customer) but i cant seem to modify records.
codeunit 50108 "Ship To Address"
{
procedure UpdateShipToAddress(
CustomerNo: Code[20];
Code: Code[20];
ShipName: Text[100];
Address: Text[100];
Address2: Text[50];
City: Code[20];
PhoneNo: Text[50];
CountryRegion: Code[10];
PostCode: Code[20];
County: Text[30];
ShipToLabel: Text[30];
BranchNo: Text[30])
var
ShipToAddressRec: Record "Ship-to Address";
begin
if ShipToAddressRec.Get(CustomerNo, Code) then begin
ShipToAddressRec.Name := ShipName;
ShipToAddressRec.Address := Address;
ShipToAddressRec."Address 2" := Address2;
ShipToAddressRec.City := City;
ShipToAddressRec."Phone No." := PhoneNo;
ShipToAddressRec."Country/Region Code" := CountryRegion;
ShipToAddressRec."Post Code" := PostCode;
ShipToAddressRec.County := County;
ShipToAddressRec."Ship to Label" := ShipToLabel;
ShipToAddressRec."Branch No" := BranchNo;
ShipToAddressRec.Modify();
end else
Error('Ship-to Address not found for Customer No. %1 and Code %2', CustomerNo, Code);
end;
[ServiceEnabled]
procedure PostUpdateShipToAddress(
CustomerNo: Code[20];
Code: Code[20];
ShipName: Text[100];
Address: Text[100];
Address2: Text[50];
City: Code[20];
PhoneNo: Text[50];
CountryRegion: Code[10];
PostCode: Code[20];
County: Text[30];
ShipToLabel: Text[30];
BranchNo: Text[30])
begin
UpdateShipToAddress(CustomerNo, Code, ShipName, Address, Address2, City, PhoneNo, CountryRegion, PostCode, County, ShipToLabel, BranchNo);
end;
}
******************PAGE***************************
page 50108 "CPT Ship To Address"
{
PageType = API;
APIPublisher = 'RS';
APIGroup = 'Shipping';
APIVersion = 'v2.0';
EntitySetName = 'shiptoaddress';
EntityName = 'shiptoaddress';
EntitySetCaption = 'shiptoaddress';
EntityCaption = 'shiptoaddress';
ChangeTrackingAllowed = true;
DelayedInsert = true;
ODataKeyFields = "Customer No.";
SourceTable = "Ship-to Address";
Extensible = true;
layout
{
area(content)
{
repeater(Group)
{
field(CustNo; rec."Customer No.")
{
Caption = 'Customer No';
ApplicationArea = all;
}
field(ShipCode; Rec.Code)
{
Caption = 'Code';
ApplicationArea = all;
}
field(ShipName; Rec.Name)
{
Caption = 'Name';
ApplicationArea = all;
}
field(Address; Rec.Address)
{
Caption = 'Address';
ApplicationArea = all;
}
field("Address2"; Rec."Address 2")
{
Caption = 'Address 2';
ApplicationArea = all;
}
field(City; Rec.City)
{
Caption = 'City';
ApplicationArea = All;
}
field("PhoneNo"; Rec."Phone No.")
{
Caption = 'PhoneNo';
ApplicationArea = all;
}
field("CountryRegion"; Rec."Country/Region Code")
{
Caption = 'Cpuntry/Region Code';
ApplicationArea = all;
}
field(PostCode; Rec."Post Code")
{
Caption = 'Post Code';
ApplicationArea = all;
}
field(County; Rec.County)
{
Caption = 'County';
ApplicationArea = all;
}
field(ShipToLabel; Rec."Ship To Label")
{
Caption = 'Ship To Label';
ApplicationArea = all;
}
field("BranchNo"; Rec."Branch No")
{
Caption = 'Branch No';
ApplicationArea = All;
}
}
}
}
}