Dataport initialise "Print Statment" even there is no code

RachelSoonRachelSoon Member Posts: 202
Dear All,
I am having this funny problem on the dataport.

I have a dataport to import some information for customer, however, this dataport will initialise "Print Statement" field whenever i run the dataport.
I have check both Table 18 and dataport, there is NO code that update "Print Statement" field.

So, finally, i got the pattern for this problem, which is :
1) If i run the dataport in design mode [meaning i open the object in design mode and didn't close and save the object], then the dataport will NOT initialise "Print Statement"

2) If i run the dataport [after close and save the object], then "Print Statement" will be initialised.

Anyone has any idea how to solve this?

Thank you.

Comments

  • garakgarak Member Posts: 3,263
    Are you sure, that the "Print Statement" is not in the Dataportfields?
    Is there a function or Codeunit that u call which set this field to true?

    Note: If you run a dataport from designmode without a commit, the datas will not be stored.

    Regards
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    Yes, i am sure there is no "print statement" field in the dataport and there is no other function that called to perform the update.

    And yes, you are right. The system will not update the data if run at design mode.

    I added a "commit" at Customer - post data item. Run the dataport at design mode and "Print Statement" got updated.

    So, now i have no idea which part of the code in the system has been to trigger to update "Print Statement", it's just a simple dataport.

    THank you.

    Regards
    Rachel
  • garakgarak Member Posts: 3,263
    can u upload the Dataporti as text here (ENU mode) also 1 or 2 textlinefiles?
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    hi, how to do upload?

    i use the attachment, but it didn't work.
    TQ
  • garakgarak Member Posts: 3,263
    export the dataport es text and import the text here as a [code]
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    Hi, Below is the code for the dataport. Please note that Dim[1], Dim[2] and SpareVatRegNo are not import into the customer field. They are the variable that accepting the value only.

    Thank you.

    OBJECT Dataport 50095 CustomerCard
    {
      OBJECT-PROPERTIES
      {
        Date=18/08/09;
        Time=[ 5:10:50 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Permissions=TableData 18=rimd,
                    TableData 349=rimd,
                    TableData 352=rimd;
        Import=Yes;
        OnPreDataport=BEGIN
                        FOR i := 1 TO 18 DO
                          Dim[i] := '';
                      END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table18;
            AutoUpdate=No;
            AutoReplace=Yes;
            OnPreDataItem=BEGIN
                            GLSetup.GET();
                            DimCode[1] := 'BRANCH';
                            DimCode[2] := 'DIVISION';
                            DimCode[3] := 'CUSTOMER GROUP';
                            DimCode[4] := 'SALESPERSON';
                            DimCode[5] := 'CUSTOMER NO';
                            DimCode[6] := 'CUSTOMER TYPE';
                          END;
    
            OnAfterImportRecord=BEGIN
                                  //Dim[1] := "Global Dimension 1 Code";
                                  //Dim[2] := "Global Dimension 2 Code";
    
                                  IF Customer."Payment Terms Code" <> '' THEN
                                    CheckPaymentTerm(Customer."Payment Terms Code");
                                  IF Customer."Payment Method Code" <> '' THEN
                                    CheckPaymentMethod(Customer."Payment Method Code");
                                  IF Customer."Shipment Method Code" <> '' THEN
                                    CheckShipmentMethod(Customer."Shipment Method Code");
                                  IF Customer."Shipping Agent Code" <> '' THEN
                                    CheckShippingAgent(Customer."Shipping Agent Code");
                                  IF Customer."Reminder Terms Code" <> '' THEN
                                    CheckReminderTerm(Customer."Reminder Terms Code");
    
                                  FOR i := 3 TO 6 DO
                                    IF (Dim[i] <> '') AND (i<>3) THEN BEGIN
                                      IF (i=4) OR (i=5) OR (i=6) THEN
                                         blnTF := TRUE
                                      ELSE
                                         blnTF := FALSE;
    
                                      CheckDimValue(DimCode[i], Dim[i], blnTF) ;
                                      CreateDimension(DimCode[i], Dim[i], Customer."No.");
                                    END;
    
                                  // CASHFLOW Default Dimension
                                  CustomerPostingGroup.RESET;
                                  CustomerPostingGroup.SETRANGE(Code, Customer."Customer Posting Group");
                                  IF CustomerPostingGroup.FIND('-') THEN
                                     BEGIN
                                        DefaultDimension.SETRANGE("No.", CustomerPostingGroup."Receivables Account");
                                        DefaultDimension.SETRANGE("Dimension Code", 'CASHFLOW');
                                        DefaultDimension.SETRANGE("Table ID",15);
                                        IF DefaultDimension.FIND('-') THEN
                                           BEGIN
    
                                              NewDefaultDimension.RESET;
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."Table ID", DATABASE::Customer);
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."No.", Customer."No.");
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."Dimension Code", 'CASHFLOW');
    
                                              IF NewDefaultDimension.FIND('-') THEN BEGIN
                                                 NewDefaultDimension."Dimension Value Code" :=DefaultDimension."Dimension Value Code";
                                                 NewDefaultDimension.MODIFY;
                                                 END
                                              ELSE
                                                 BEGIN
                                                 NewDefaultDimension.INIT;
                                                 NewDefaultDimension."Table ID" := DATABASE::Customer;
                                                 NewDefaultDimension."No." := Customer."No.";
                                                 NewDefaultDimension."Dimension Code" := 'CASHFLOW';
                                                 NewDefaultDimension."Dimension Value Code" := DefaultDimension."Dimension Value Code";
                                                 NewDefaultDimension."Value Posting" := NewDefaultDimension."Value Posting"::"Same Code";
                                                 NewDefaultDimension.INSERT;
                                                 END;
                                        END;
                                     END;
    
                                  // Default Value
                                  "Payment Terms Code" := '0';
                                  "Payment Method Code" := 'Cheque';
                                  //"Global Dimension 1 Code" := Dim[1];
                                  //"Global Dimension 2 Code" := Dim[2];
                                END;
    
            OnPostDataItem=BEGIN
                             COMMIT;
                           END;
    
          }
          FIELDS
          {
            {      ;     ;"No."               ;CallFieldValidate=Yes }
            {      ;     ;Name                 }
            {      ;     ;"Search Name"        }
            {      ;     ;"Credit Limit (LCY)" }
            {      ;     ;"Gen. Bus. Posting Group" }
            {      ;     ;"Customer Posting Group" }
            {      ;     ;Address              }
            {      ;     ;"Address 2"          }
            {      ;     ;City                 }
            {      ;     ;County               }
            {      ;     ;"Post Code"          }
            {      ;     ;"Country Code"       }
            {      ;     ;"Phone No."          }
            {      ;     ;"Fax No."            }
            {      ;     ;"E-Mail"             }
            {      ;     ;Contact              }
            {      ;     ;"Application Method" }
            {      ;     ;Dim[1]               }
            {      ;     ;Dim[2]               }
            {      ;     ;Dim[3]               }
            {      ;     ;Dim[6]               }
            {      ;     ;Dim[4]               }
            {      ;     ;Dim[5]               }
            {      ;     ;"Last Date Modified" }
            {      ;     ;"VAT Registration No." }
            {      ;     ;SpareVatRegNo        }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          Dim1@1000000000 : Code[20];
          Dim4@1000000001 : Code[20];
          DIm5@1000000002 : Code[20];
          Dim7@1000000003 : Code[20];
          Dim8@1000000004 : Code[20];
          Dim13@1000000005 : Code[20];
          Dim18@1000000006 : Code[20];
          Dim1Code@1000000013 : Code[20];
          Dim4Code@1000000012 : Code[20];
          DIm5Code@1000000011 : Code[20];
          Dim7Code@1000000010 : Code[20];
          Dim8Code@1000000009 : Code[20];
          Dim13Code@1000000008 : Code[20];
          Dim18Code@1000000007 : Code[20];
          Dim@1000000014 : ARRAY [18] OF Code[20];
          DimCode@1000000015 : ARRAY [18] OF Code[20];
          i@1000000016 : Integer;
          blnTF@1000000017 : Boolean;
          FieldMapping@1000000018 : Record 50002;
          CustomerPostingGroup@1000000019 : Record 92;
          DefaultDimension@1000000020 : Record 352;
          NewDefaultDimension@1000000021 : Record 352;
          cust@1000000022 : Record 18;
          recFile@1000000023 : Record 2000000022;
          GLSetup@1000000024 : Record 311;
          CustFileName@1000000025 : Text[250];
          File1@1000000026 : File;
          JobSchedSetup@1000000027 : Record 50005;
          InStreamObj@1000000029 : InStream;
          int@1000000030 : Integer;
          FileNameBuf@1000000031 : Text[250];
          SpareVatRegNo@1000000028 : Text[20];
    
        PROCEDURE GetDimensionCode@1000000002(DimensionGroup@1000000000 : Integer) DimCode : Code[20];
        VAR
          Dimension@1000000001 : Record 348;
        BEGIN
          DimCode := '';
    
          Dimension.RESET;
          //Dimension.SETRANGE(Dimension."Dimension Group", DimensionGroup);
    
          IF Dimension.FIND('-') THEN
            DimCode := Dimension.Code
          ELSE
            ERROR ('Please create dimension %1', DimensionGroup);
        END;
    
        PROCEDURE CreateDimension@1000000009(DimCode@1000000000 : Code[20];DimValue@1000000001 : Code[20];CustNo@1000000003 : Code[20]);
        VAR
          DefaultDim@1000000002 : Record 352;
        BEGIN
          DefaultDim.RESET;
          DefaultDim.SETRANGE(DefaultDim."Table ID", DATABASE::Customer);
          DefaultDim.SETRANGE(DefaultDim."No.", CustNo);
          DefaultDim.SETRANGE(DefaultDim."Dimension Code", DimCode);
    
          IF DefaultDim.FIND('-') THEN BEGIN
            DefaultDim."Dimension Value Code" := DimValue;
            DefaultDim.MODIFY;
          END ELSE BEGIN
            DefaultDim.INIT;
            DefaultDim."Table ID" := DATABASE::Customer;
            DefaultDim."No." := CustNo;
            DefaultDim."Dimension Code" := DimCode;
            DefaultDim."Dimension Value Code" := DimValue;
            IF i = 4 THEN
               DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Code Mandatory"
            ELSE
               DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Same Code";
            DefaultDim.INSERT;
          END;
        END;
    
        PROCEDURE CheckDimValue@1000000000(VAR DimCode@1000000000 : Code[20];VAR DimValue@1000000001 : Code[20];VAR CreateNew@1000000003 : Boolean);
        VAR
          DimensionValue@1000000002 : Record 349;
        BEGIN
          DimensionValue.RESET;
          DimensionValue.SETRANGE(DimensionValue."Dimension Code", DimCode);
          DimensionValue.SETRANGE(DimensionValue.Code, DimValue);
          IF DimensionValue.ISEMPTY THEN
             IF CreateNew THEN
                CreateDimValue(DimCode, DimValue)
             ELSE
                ERROR('Invalid dimension value, Dimension Code : %1, Dimension Value : %2', DimCode, DimValue);
        END;
    
        PROCEDURE CheckPaymentTerm@1000000007(PaymentTermCode@1000000001 : Code[10]);
        VAR
          PaymentTerm@1000000000 : Record 3;
        BEGIN
          PaymentTerm.RESET;
          PaymentTerm.SETRANGE(PaymentTerm.Code, PaymentTermCode);
          IF PaymentTerm.ISEMPTY THEN
            ERROR('Invalid Payment Terms Code : %1', PaymentTermCode);
        END;
    
        PROCEDURE CheckPaymentMethod@1000000010(PaymentMethodCode@1000000000 : Code[10]);
        VAR
          PaymentMethod@1000000001 : Record 289;
        BEGIN
          PaymentMethod.RESET;
          PaymentMethod.SETRANGE(PaymentMethod.Code, PaymentMethodCode);
          IF PaymentMethod.ISEMPTY THEN
            ERROR('Invalid payment method code : %1', PaymentMethodCode);
        END;
    
        PROCEDURE CheckShipmentMethod@1000000016(ShipmentMethodCode@1000000000 : Code[10]);
        VAR
          ShipmentMethod@1000000001 : Record 10;
        BEGIN
          ShipmentMethod.RESET;
          ShipmentMethod.SETRANGE(ShipmentMethod.Code, ShipmentMethodCode);
          IF ShipmentMethod.ISEMPTY THEN
            ERROR('Invalid shipment method code : %1', ShipmentMethodCode);
        END;
    
        PROCEDURE CheckShippingAgent@1000000018(ShippingAgentCode@1000000000 : Code[10]);
        VAR
          ShippingAgent@1000000001 : Record 291;
        BEGIN
          ShippingAgent.RESET;
          ShippingAgent.SETRANGE(ShippingAgent.Code, ShippingAgentCode);
          IF ShippingAgent.ISEMPTY THEN
            ERROR('Invalid shipping agent : %1', ShippingAgentCode);
        END;
    
        PROCEDURE CheckReminderTerm@1000000021(ReminderTermCode@1000000000 : Code[10]);
        VAR
          ReminderTerm@1000000001 : Record 292;
        BEGIN
          ReminderTerm.RESET;
          ReminderTerm.SETRANGE(ReminderTerm.Code, ReminderTermCode);
          IF ReminderTerm.ISEMPTY THEN
            ERROR('Invalid reminder terms code : %1', ReminderTermCode);
        END;
    
        PROCEDURE CheckPostcode@1000000001(PostCode@1000000001 : Code[10]);
        VAR
          PostCodeTable@1000000000 : Record 225;
        BEGIN
          PostCodeTable.RESET;
          PostCodeTable.SETRANGE(PostCodeTable.Code, PostCode);
          IF PostCodeTable.ISEMPTY THEN
            ERROR('Invalid Post Code : %1', PostCode);
        END;
    
        PROCEDURE CreateDimValue@1000000003(VAR DimCode@1000000000 : Code[20];VAR DimValue@1000000001 : Code[20]);
        VAR
          DimensionValue@1000000003 : Record 349;
        BEGIN
          DimensionValue.INIT;
          DimensionValue."Dimension Code" := DimCode;
          DimensionValue.Code := DimValue;
          DimensionValue.Name := DimValue;
          DimensionValue."Dimension Value Type" := DimensionValue."Dimension Value Type"::Standard;
          DimensionValue.INSERT;
        END;
    
        BEGIN
        END.
      }
    }
    
    
    
  • garakgarak Member Posts: 3,263
    is there some Code behind the Field "No." on the table 18 (Cutomer)?
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    I have exported Table 18 as text and can not find "Print Statements" except field 42.
  • DaveTDaveT Member Posts: 1,039
    Hi,

    I suspect the problem is arising from changing the Global Dimensions. In the Default Dimension table there is code which is dangerous if used out of Standard Nav
    i.e.
    Code
        DATABASE::Customer: BEGIN
          IF Cust.GET("No.") THEN BEGIN
            CASE GlobalDimCodeNo OF
              1:Cust."Global Dimension 1 Code" := NewDimValue;
              2:Cust."Global Dimension 2 Code" := NewDimValue;
            END;
            Cust.MODIFY(TRUE);
          END;
        END;
    
    This assumes than a customer always exists - I would perfer to see the modify withing the IF Cust.GET("No.") THEN
    Try the upload without the 2 global dimension to test it out.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • RachelSoonRachelSoon Member Posts: 202
    Hi Dave,
    The dataport did not update the 2 global dimension. In fact, i have try to comment the code that highlighted by you, and try the dataport. The result is still the same.
  • SavatageSavatage Member Posts: 7,142
    Did you look at the InitValue property of the field. Is it set to YES?
  • DaveTDaveT Member Posts: 1,039
    Hi Rachel,

    Can you post the code again within the
    [ /code] box again as I cannot import the dataport due to the indentation and I will have a look. Not sure why it didn't work but should appear like this in the preview
    [code]MyDataport
    
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • RachelSoonRachelSoon Member Posts: 202
    OBJECT Dataport 50095 CustomerCard
    {
      OBJECT-PROPERTIES
      {
        Date=18/08/09;
        Time=[ 5:10:50 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Permissions=TableData 18=rimd,
                    TableData 349=rimd,
                    TableData 352=rimd;
        Import=Yes;
        OnPreDataport=BEGIN
                        FOR i := 1 TO 18 DO
                          Dim[i] := '';
                      END;
    
      }
      DATAITEMS
      {
        { PROPERTIES
          {
            DataItemTable=Table18;
            AutoUpdate=No;
            AutoReplace=Yes;
            OnPreDataItem=BEGIN
                            GLSetup.GET();
                            DimCode[1] := 'BRANCH';
                            DimCode[2] := 'DIVISION';
                            DimCode[3] := 'CUSTOMER GROUP';
                            DimCode[4] := 'SALESPERSON';
                            DimCode[5] := 'CUSTOMER NO';
                            DimCode[6] := 'CUSTOMER TYPE';
                          END;
    
            OnAfterImportRecord=BEGIN
                                  //Dim[1] := "Global Dimension 1 Code";
                                  //Dim[2] := "Global Dimension 2 Code";
    
                                  IF Customer."Payment Terms Code" <> '' THEN
                                    CheckPaymentTerm(Customer."Payment Terms Code");
                                  IF Customer."Payment Method Code" <> '' THEN
                                    CheckPaymentMethod(Customer."Payment Method Code");
                                  IF Customer."Shipment Method Code" <> '' THEN
                                    CheckShipmentMethod(Customer."Shipment Method Code");
                                  IF Customer."Shipping Agent Code" <> '' THEN
                                    CheckShippingAgent(Customer."Shipping Agent Code");
                                  IF Customer."Reminder Terms Code" <> '' THEN
                                    CheckReminderTerm(Customer."Reminder Terms Code");
    
                                  FOR i := 3 TO 6 DO
                                    IF (Dim[i] <> '') AND (i<>3) THEN BEGIN
                                      IF (i=4) OR (i=5) OR (i=6) THEN
                                         blnTF := TRUE
                                      ELSE
                                         blnTF := FALSE;
    
                                      CheckDimValue(DimCode[i], Dim[i], blnTF) ;
                                      CreateDimension(DimCode[i], Dim[i], Customer."No.");
                                    END;
    
                                  // CASHFLOW Default Dimension
                                  CustomerPostingGroup.RESET;
                                  CustomerPostingGroup.SETRANGE(Code, Customer."Customer Posting Group");
                                  IF CustomerPostingGroup.FIND('-') THEN
                                     BEGIN
                                        DefaultDimension.SETRANGE("No.", CustomerPostingGroup."Receivables Account");
                                        DefaultDimension.SETRANGE("Dimension Code", 'CASHFLOW');
                                        DefaultDimension.SETRANGE("Table ID",15);
                                        IF DefaultDimension.FIND('-') THEN
                                           BEGIN
    
                                              NewDefaultDimension.RESET;
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."Table ID", DATABASE::Customer);
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."No.", Customer."No.");
                                              NewDefaultDimension.SETRANGE(NewDefaultDimension."Dimension Code", 'CASHFLOW');
    
                                              IF NewDefaultDimension.FIND('-') THEN BEGIN
                                                 NewDefaultDimension."Dimension Value Code" :=DefaultDimension."Dimension Value Code";
                                                 NewDefaultDimension.MODIFY;
                                                 END
                                              ELSE
                                                 BEGIN
                                                 NewDefaultDimension.INIT;
                                                 NewDefaultDimension."Table ID" := DATABASE::Customer;
                                                 NewDefaultDimension."No." := Customer."No.";
                                                 NewDefaultDimension."Dimension Code" := 'CASHFLOW';
                                                 NewDefaultDimension."Dimension Value Code" := DefaultDimension."Dimension Value Code";
                                                 NewDefaultDimension."Value Posting" := NewDefaultDimension."Value Posting"::"Same Code";
                                                 NewDefaultDimension.INSERT;
                                                 END;
                                        END;
                                     END;
    
                                  // Default Value
                                  "Payment Terms Code" := '0';
                                  "Payment Method Code" := 'Cheque';
                                  //"Global Dimension 1 Code" := Dim[1];
                                  //"Global Dimension 2 Code" := Dim[2];
                                END;
    
            OnPostDataItem=BEGIN
                             COMMIT;
                           END;
    
          }
          FIELDS
          {
            {      ;     ;"No."               ;CallFieldValidate=Yes }
            {      ;     ;Name                 }
            {      ;     ;"Search Name"        }
            {      ;     ;"Credit Limit (LCY)" }
            {      ;     ;"Gen. Bus. Posting Group" }
            {      ;     ;"Customer Posting Group" }
            {      ;     ;Address              }
            {      ;     ;"Address 2"          }
            {      ;     ;City                 }
            {      ;     ;County               }
            {      ;     ;"Post Code"          }
            {      ;     ;"Country Code"       }
            {      ;     ;"Phone No."          }
            {      ;     ;"Fax No."            }
            {      ;     ;"E-Mail"             }
            {      ;     ;Contact              }
            {      ;     ;"Application Method" }
            {      ;     ;Dim[1]               }
            {      ;     ;Dim[2]               }
            {      ;     ;Dim[3]               }
            {      ;     ;Dim[6]               }
            {      ;     ;Dim[4]               }
            {      ;     ;Dim[5]               }
            {      ;     ;"Last Date Modified" }
            {      ;     ;"VAT Registration No." }
            {      ;     ;SpareVatRegNo        }
          }
           }
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=9020;
          Height=3410;
        }
        CONTROLS
        {
        }
      }
      CODE
      {
        VAR
          Dim1@1000000000 : Code[20];
          Dim4@1000000001 : Code[20];
          DIm5@1000000002 : Code[20];
          Dim7@1000000003 : Code[20];
          Dim8@1000000004 : Code[20];
          Dim13@1000000005 : Code[20];
          Dim18@1000000006 : Code[20];
          Dim1Code@1000000013 : Code[20];
          Dim4Code@1000000012 : Code[20];
          DIm5Code@1000000011 : Code[20];
          Dim7Code@1000000010 : Code[20];
          Dim8Code@1000000009 : Code[20];
          Dim13Code@1000000008 : Code[20];
          Dim18Code@1000000007 : Code[20];
          Dim@1000000014 : ARRAY [18] OF Code[20];
          DimCode@1000000015 : ARRAY [18] OF Code[20];
          i@1000000016 : Integer;
          blnTF@1000000017 : Boolean;
          FieldMapping@1000000018 : Record 50002;
          CustomerPostingGroup@1000000019 : Record 92;
          DefaultDimension@1000000020 : Record 352;
          NewDefaultDimension@1000000021 : Record 352;
          cust@1000000022 : Record 18;
          recFile@1000000023 : Record 2000000022;
          GLSetup@1000000024 : Record 311;
          CustFileName@1000000025 : Text[250];
          File1@1000000026 : File;
          JobSchedSetup@1000000027 : Record 50005;
          InStreamObj@1000000029 : InStream;
          int@1000000030 : Integer;
          FileNameBuf@1000000031 : Text[250];
          SpareVatRegNo@1000000028 : Text[20];
    
        PROCEDURE GetDimensionCode@1000000002(DimensionGroup@1000000000 : Integer) DimCode : Code[20];
        VAR
          Dimension@1000000001 : Record 348;
        BEGIN
          DimCode := '';
    
          Dimension.RESET;
          //Dimension.SETRANGE(Dimension."Dimension Group", DimensionGroup);
    
          IF Dimension.FIND('-') THEN
            DimCode := Dimension.Code
          ELSE
            ERROR ('Please create dimension %1', DimensionGroup);
        END;
    
        PROCEDURE CreateDimension@1000000009(DimCode@1000000000 : Code[20];DimValue@1000000001 : Code[20];CustNo@1000000003 : Code[20]);
        VAR
          DefaultDim@1000000002 : Record 352;
        BEGIN
          DefaultDim.RESET;
          DefaultDim.SETRANGE(DefaultDim."Table ID", DATABASE::Customer);
          DefaultDim.SETRANGE(DefaultDim."No.", CustNo);
          DefaultDim.SETRANGE(DefaultDim."Dimension Code", DimCode);
    
          IF DefaultDim.FIND('-') THEN BEGIN
            DefaultDim."Dimension Value Code" := DimValue;
            DefaultDim.MODIFY;
          END ELSE BEGIN
            DefaultDim.INIT;
            DefaultDim."Table ID" := DATABASE::Customer;
            DefaultDim."No." := CustNo;
            DefaultDim."Dimension Code" := DimCode;
            DefaultDim."Dimension Value Code" := DimValue;
            IF i = 4 THEN
               DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Code Mandatory"
            ELSE
               DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Same Code";
            DefaultDim.INSERT;
          END;
        END;
    
        PROCEDURE CheckDimValue@1000000000(VAR DimCode@1000000000 : Code[20];VAR DimValue@1000000001 : Code[20];VAR CreateNew@1000000003 : Boolean);
        VAR
          DimensionValue@1000000002 : Record 349;
        BEGIN
          DimensionValue.RESET;
          DimensionValue.SETRANGE(DimensionValue."Dimension Code", DimCode);
          DimensionValue.SETRANGE(DimensionValue.Code, DimValue);
          IF DimensionValue.ISEMPTY THEN
             IF CreateNew THEN
                CreateDimValue(DimCode, DimValue)
             ELSE
                ERROR('Invalid dimension value, Dimension Code : %1, Dimension Value : %2', DimCode, DimValue);
        END;
    
        PROCEDURE CheckPaymentTerm@1000000007(PaymentTermCode@1000000001 : Code[10]);
        VAR
          PaymentTerm@1000000000 : Record 3;
        BEGIN
          PaymentTerm.RESET;
          PaymentTerm.SETRANGE(PaymentTerm.Code, PaymentTermCode);
          IF PaymentTerm.ISEMPTY THEN
            ERROR('Invalid Payment Terms Code : %1', PaymentTermCode);
        END;
    
        PROCEDURE CheckPaymentMethod@1000000010(PaymentMethodCode@1000000000 : Code[10]);
        VAR
          PaymentMethod@1000000001 : Record 289;
        BEGIN
          PaymentMethod.RESET;
          PaymentMethod.SETRANGE(PaymentMethod.Code, PaymentMethodCode);
          IF PaymentMethod.ISEMPTY THEN
            ERROR('Invalid payment method code : %1', PaymentMethodCode);
        END;
    
        PROCEDURE CheckShipmentMethod@1000000016(ShipmentMethodCode@1000000000 : Code[10]);
        VAR
          ShipmentMethod@1000000001 : Record 10;
        BEGIN
          ShipmentMethod.RESET;
          ShipmentMethod.SETRANGE(ShipmentMethod.Code, ShipmentMethodCode);
          IF ShipmentMethod.ISEMPTY THEN
            ERROR('Invalid shipment method code : %1', ShipmentMethodCode);
        END;
    
        PROCEDURE CheckShippingAgent@1000000018(ShippingAgentCode@1000000000 : Code[10]);
        VAR
          ShippingAgent@1000000001 : Record 291;
        BEGIN
          ShippingAgent.RESET;
          ShippingAgent.SETRANGE(ShippingAgent.Code, ShippingAgentCode);
          IF ShippingAgent.ISEMPTY THEN
            ERROR('Invalid shipping agent : %1', ShippingAgentCode);
        END;
    
        PROCEDURE CheckReminderTerm@1000000021(ReminderTermCode@1000000000 : Code[10]);
        VAR
          ReminderTerm@1000000001 : Record 292;
        BEGIN
          ReminderTerm.RESET;
          ReminderTerm.SETRANGE(ReminderTerm.Code, ReminderTermCode);
          IF ReminderTerm.ISEMPTY THEN
            ERROR('Invalid reminder terms code : %1', ReminderTermCode);
        END;
    
        PROCEDURE CheckPostcode@1000000001(PostCode@1000000001 : Code[10]);
        VAR
          PostCodeTable@1000000000 : Record 225;
        BEGIN
          PostCodeTable.RESET;
          PostCodeTable.SETRANGE(PostCodeTable.Code, PostCode);
          IF PostCodeTable.ISEMPTY THEN
            ERROR('Invalid Post Code : %1', PostCode);
        END;
    
        PROCEDURE CreateDimValue@1000000003(VAR DimCode@1000000000 : Code[20];VAR DimValue@1000000001 : Code[20]);
        VAR
          DimensionValue@1000000003 : Record 349;
        BEGIN
          DimensionValue.INIT;
          DimensionValue."Dimension Code" := DimCode;
          DimensionValue.Code := DimValue;
          DimensionValue.Name := DimValue;
          DimensionValue."Dimension Value Type" := DimensionValue."Dimension Value Type"::Standard;
          DimensionValue.INSERT;
        END;
    
        BEGIN
        END.
      }
    }
    
    
  • RachelSoonRachelSoon Member Posts: 202
    The InitValue property for field 42 is <undefined>
  • garakgarak Member Posts: 3,263
    Ok, your dataportoptions are

    AutoReplace=Yes; -->
    That means, that if a rec exist in your file and in the table, the rec in the table will be replaced with the datas from the file. All other fields (that are not in the file) will be set to the default value

    and

    AutoUpdate=No; -->
    That means, that if an Rec in the table exist with the same Primary key, only the fields from the dataport file will be updated. All other fields are not changed.

    So, you have set the Update to NO and Replace to ÝES. Now, if you import the customer, and this customer exist and in the existing Customer are some fields modified, these fields will be set to the default value.

    Are these all new customers or existing customers?

    Regards
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    they are existing customer.
  • DaveTDaveT Member Posts: 1,039
    Hi Rachel,

    Your problem is the properties on the Customer dataitem. You have set AutoUpdate to No and AutoReplace to Yes. This means that the dataport will fully replace the entire record with the data from the dataport and initialise all other variables. I suspect as Harry points out that there is an InitValue on the Print Statements. To replace just the fields you are importing revert back to defaults i.e. AutoUpdate - Yes AutoReplace - No
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • garakgarak Member Posts: 3,263
    RachelSoon wrote:
    they are existing customer.


    Then u delete all existing values in all fields that are not in the dataport (like name 2)
    Do you make it right, it works too!
  • RachelSoonRachelSoon Member Posts: 202
    Hi Garak,
    Thank you for your suggestion on the Autoupdate and AutoReplace.

    I change the property AutoUpdate to Yes and AutoReplace to No, and it works!

    The "Print Statement" field does not get updated.

    Thank you all for helping me on this.

    Regards
    Rachel
Sign In or Register to comment.