Sales Header record cannot be saved because some information on the page is not up-to-date. PostCode
samantha73
Member Posts: 119
Hi All
I'm trying to find a way use the shipto address postcode to lookup a custom table to get the dimensions. The post code field doesnot trigger OnAfterValidate. So I use below event subscriber
However when running the code error comes on page as below
Sales Header record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it, and try again
Is there a better way to capture postcode initial insert and subsequent update events so I can use the postcode for updating another field - say dimensions? Below is the code:
I'm trying to find a way use the shipto address postcode to lookup a custom table to get the dimensions. The post code field doesnot trigger OnAfterValidate. So I use below event subscriber
{
[EventSubscriber(ObjectType::Table, Database::"Sales Header", OnAfterLookupShipToPostCode, '', false, false)]
local procedure OnafterLookup(var SalesHeader: Record "Sales Header")
However when running the code error comes on page as below
Sales Header record cannot be saved because some information on the page is not up-to-date. Close the page, reopen it, and try again
Is there a better way to capture postcode initial insert and subsequent update events so I can use the postcode for updating another field - say dimensions? Below is the code:
begin
Rec := SalesHeader;
Message('OnAfterUpdateEvent');//debug
if Rec.IsTemporary then
Exit;
//todo check SO status open
GenLedgerSetup.Get();
Dim3Code := GenLedgerSetup."Shortcut Dimension 3 Code";
//Postcode lookup from custom table
IsConversionSuccessful := Evaluate(ShipToPostCodeInt, Rec."Ship-to Post Code");
if not IsConversionSuccessful then
Error('Post code value "%1" cannot be converted to an integer. Check Post code.', Rec."Ship-to Post Code");
//Find Territory based on post code
PostCodeTerritory.Reset();
PostCodeTerritory.SetFilter(StartPostCode, '<=%1', ShipToPostCodeInt);
PostCodeTerritory.SetFilter(EndPostCode, '>=%1', ShipToPostCodeInt);
if PostCodeTerritory.FindFirst() then begin
Message('Territory code found for Post code %1 and territory %2', ShipToPostCodeInt, PostCodeTerritory.TerritoryID);
Dim3Value := PostCodeTerritory.TerritoryID
end
else
Error('Territory code not found for Post code %1', Rec."Ship-to Post Code");
//Dim3 territory
DimSetEntryTemp.init();
DimSetEntryTemp.validate("Dimension Code", Dim3Code);
DimSetEntryTemp.validate("Dimension Value Code", Dim3Value);
DimSetEntryTemp.Insert();
UpdateDimSetOnSalesHeader(Rec, DimSetEntryTemp);
Rec.Modify()
end;
procedure UpdateDimSetOnSalesHeader(var Header: Record "Sales Header"; var ToAddDims: Record "Dimension Set Entry" temporary)
var
DimMgt: Codeunit DimensionManagement;
NewDimSet: Record "Dimension Set Entry" temporary;
begin
DimMgt.GetDimensionSet(NewDimSet, header."Dimension Set ID");
if ToAddDims.FindSet() then
repeat
if NewDimSet.Get(header."Dimension Set ID", ToAddDims."Dimension Code") then begin
NewDimSet.validate("Dimension Value Code", ToAddDims."Dimension Value Code");
NewDimSet.Modify();
end else begin
NewDimSet := ToAddDims;
NewDimSet."Dimension Set ID" := Header."Dimension Set ID";
NewDimSet.Insert();
end;
until ToAddDims.Next() = 0;
Header."Dimension Set ID" := DimMgt.GetDimensionSetID(NewDimSet);
DimMgt.UpdateGlobalDimFromDimSetID(Header."Dimension Set ID", Header."Shortcut Dimension 1 Code", Header."Shortcut Dimension 2 Code");
end;
}
0
Best Answer
-
Ok thanksUnited Kingdom0
Answers
-
It has been a while since you have posted this question. Is this still an issue?United Kingdom0
-
I have resolved by removing or changing the modify event it seems there are two modify events - one system already so conflicting0
-
Ok thanksUnited Kingdom0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
