Tuesday, January 24, 2012

Destination root by Online Map in Dynamics NAV 2009 R2




I got a requirement to develop to show the destination root. Sales order contain Customer Ship to City between Item Location Code (city of the address).

Created a function in Sales Line table called DisplayMap Define Local Variables

Name                  DataType               Subtype              
MapPoint            Record                Online Map Setup            
MapMgt              Codeunit             Online Map Management
RVCustomer       Record                 Customer
RVLocation         Record                  Location              


DisplayMap Function Contains the below code.

GetSalesHeader;
IF RVCustomer.GET("Sell-to Customer No.") THEN;
IF Rvlocation.GET("Location Code") THEN;
IF MapPoint.FIND('-') THEN
  MapMgt.MakeSelection1(DATABASE::"Sales Header",SalesHeader.GETPOSITION,Rvlocation.GETPOSITION,"Location Code")
ELSE
MESSAGE(Text50000);
{Text50000 - Contains
’ Before you can use Online Map, you must fill in the Online Map Setup window.\See Setting Up Online Map in Help.’
}

In Online Map Management you have to create a new function MakeSelection1 .

MakeSelection1(TableID : Integer;Position : Text[1000];LocationPosition :     Text[1000];LocationCode : Code[20])
MapSetup.GET;
IF MapSetup."Default Language Code" = '' THEN
  ERROR(STRSUBSTNO(Text003,MapSetup.FIELDCAPTION("Default Language Code")));
SelectAddress1(TableID,Position,1,MapSetup."Distance In",MapSetup.Route,LocationPosition);

In Online Map Management you have to create a new function SelectAddress1

SelectAddress1(TableNo : Integer;RecPosition : Text[1000];Direction : 'To Other,From Other,To Company,From Company';Distance : 'Miles,K
IF Direction IN [Direction::"To Other",Direction::"From Other"] THEN BEGIN
OnlineMapSetup.GET;
Distance := OnlineMapSetup."Distance In";
Route := OnlineMapSetup.Route;

END ELSE BEGIN
  OnlineMapSetup.GET;
  CompanyInfo.GET;
END;

CASE Direction OF
  Direction::"To Other":
    BEGIN
      ProcessDirections(
        TableNo,RecPosition,
        OnlineMapAddressSelector.GetTableNo,OnlineMapAddressSelector.GetRecPosition,
        Distance,Route)
    END;
  Direction::"From Other":
    BEGIN
      ProcessDirections(
        DATABASE::Location,LocationCode,
        TableNo,RecPosition,
        Distance,Route);
    END;
  Direction::"To Company":
    BEGIN
      ProcessDirections(
        TableNo,RecPosition,
        DATABASE::"Company Information",CompanyInfo.GETPOSITION,
        OnlineMapSetup."Distance In",OnlineMapSetup.Route);
    END;
  Direction::"From Company":
    BEGIN
      ProcessDirections(
        DATABASE::"Company Information",CompanyInfo.GETPOSITION,
        TableNo,RecPosition,
        OnlineMapSetup."Distance In",OnlineMapSetup.Route);
    END;
END

Create an action to Call DisplayMap Function in Sales Line Table.



No comments:

Post a Comment