RunModal Error

vikram7_dabasvikram7_dabas Member Posts: 611
Dear concer
I m using Nav 4.0 SP3 database.I have created 1 sales order when I m going to validate again sell to customer No. field then it is showing me error like:

The following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked).

Form.RunModal() is not allowed in write transactions.

CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.

Report.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'Report.RunModal(...,FALSE)' is allowed.

DataPort.RunModal() is allowed in write transactions only if 'RequestForm = FALSE'. For example, 'DataPort.RunModal(...,FALSE)' is allowed.

Use the COMMIT function to save the changes before this call, or structure the code differently.

Its the Base DB not customisation has been done in Table sales header.
Vikram Dabas
Navision Technical Consultant

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Its the Base DB not customisation has been done in Table sales header.

    i dont think so..

    anyhow chech this code with ur sales header table Sell-to Customer No. - OnValidate()
    TESTFIELD(Status,Status::Open);
    IF ("Sell-to Customer No." <> xRec."Sell-to Customer No.") AND
       (xRec."Sell-to Customer No." <> '')
    THEN BEGIN
      IF ("Opportunity No." <> '') AND ("Document Type" IN ["Document Type"::Quote,"Document Type"::Order]) THEN
        ERROR(
          Text062,
          FIELDCAPTION("Sell-to Customer No."),
          FIELDCAPTION("Opportunity No."),
          "Opportunity No.",
          "Document Type");
      IF HideValidationDialog OR NOT GUIALLOWED THEN
        Confirmed := TRUE
      ELSE
        Confirmed := CONFIRM(Text004,FALSE,FIELDCAPTION("Sell-to Customer No."));
      IF Confirmed THEN BEGIN
        SalesLine.SETRANGE("Document Type","Document Type");
        SalesLine.SETRANGE("Document No.","No.");
        IF "Sell-to Customer No." = '' THEN BEGIN
          IF SalesLine.FINDFIRST THEN
            ERROR(
              Text005,
              FIELDCAPTION("Sell-to Customer No."));
          INIT;
          SalesSetup.GET;
          "No. Series" := xRec."No. Series";
          InitRecord;
          IF xRec."Shipping No." <> '' THEN BEGIN
            "Shipping No. Series" := xRec."Shipping No. Series";
            "Shipping No." := xRec."Shipping No.";
          END;
          IF xRec."Posting No." <> '' THEN BEGIN
            "Posting No. Series" := xRec."Posting No. Series";
            "Posting No." := xRec."Posting No.";
          END;
          IF xRec."Return Receipt No." <> '' THEN BEGIN
            "Return Receipt No. Series" := xRec."Return Receipt No. Series";
            "Return Receipt No." := xRec."Return Receipt No.";
          END;
          IF xRec."Prepayment No." <> '' THEN BEGIN
            "Prepayment No. Series" := xRec."Prepayment No. Series";
            "Prepayment No." := xRec."Prepayment No.";
          END;
          IF xRec."Prepmt. Cr. Memo No." <> '' THEN BEGIN
            "Prepmt. Cr. Memo No. Series" := xRec."Prepmt. Cr. Memo No. Series";
            "Prepmt. Cr. Memo No." := xRec."Prepmt. Cr. Memo No.";
          END;
          EXIT;
        END;
        IF "Document Type" = "Document Type"::Order THEN
          SalesLine.SETFILTER("Quantity Shipped",'<>0')
        ELSE IF "Document Type" = "Document Type"::Invoice THEN BEGIN
            SalesLine.SETRANGE("Sell-to Customer No.",xRec."Sell-to Customer No.");
            SalesLine.SETFILTER("Shipment No.",'<>%1','');
          END;
    
        IF SalesLine.FINDFIRST THEN
          IF "Document Type" = "Document Type"::Order THEN
            SalesLine.TESTFIELD("Quantity Shipped",0)
          ELSE
            SalesLine.TESTFIELD("Shipment No.",'');
        SalesLine.SETRANGE("Shipment No.");
        SalesLine.SETRANGE("Quantity Shipped");
    
        IF "Document Type" = "Document Type"::Order THEN BEGIN
          SalesLine.SETFILTER("Prepmt. Amt. Inv.",'<>0');
          IF SalesLine.FIND('-') THEN
            SalesLine.TESTFIELD("Prepmt. Amt. Inv.",0);
          SalesLine.SETRANGE("Prepmt. Amt. Inv.");
        END;
    
        IF "Document Type" = "Document Type"::"Return Order" THEN
          SalesLine.SETFILTER("Return Qty. Received",'<>0')
        ELSE
          IF "Document Type" = "Document Type"::"Credit Memo" THEN BEGIN
            SalesLine.SETRANGE("Sell-to Customer No.",xRec."Sell-to Customer No.");
            SalesLine.SETFILTER("Return Receipt No.",'<>%1','');
          END;
    
        IF SalesLine.FINDFIRST THEN
          IF "Document Type" = "Document Type"::"Return Order" THEN
            SalesLine.TESTFIELD("Return Qty. Received",0)
          ELSE
            SalesLine.TESTFIELD("Return Receipt No.",'');
        SalesLine.RESET
      END ELSE BEGIN
        Rec := xRec;
        EXIT;
      END;
    END;
    
    IF ("Document Type" = "Document Type"::Order) AND
       (xRec."Sell-to Customer No." <> "Sell-to Customer No.")
    THEN BEGIN
      SalesLine.SETRANGE("Document Type",SalesLine."Document Type"::Order);
      SalesLine.SETRANGE("Document No.","No.");
      SalesLine.SETFILTER("Purch. Order Line No.",'<>0');
      IF NOT SalesLine.ISEMPTY THEN
        ERROR(
          Text006,
          FIELDCAPTION("Sell-to Customer No."));
      SalesLine.RESET;
    END;
    
    GetCust("Sell-to Customer No.");
    
    Cust.CheckBlockedCustOnDocs(Cust,"Document Type",FALSE,FALSE);
    Cust.TESTFIELD("Gen. Bus. Posting Group");
    "Sell-to Customer Template Code" := '';
    "Sell-to Customer Name" := Cust.Name;
    "Sell-to Customer Name 2" := Cust."Name 2";
    "Sell-to Address" := Cust.Address;
    "Sell-to Address 2" := Cust."Address 2";
    "Sell-to City" := Cust.City;
    "Sell-to Post Code" := Cust."Post Code";
    "Sell-to County" := Cust.County;
    "Sell-to Country/Region Code" := Cust."Country/Region Code";
    IF NOT SkipSellToContact THEN
      "Sell-to Contact" := Cust.Contact;
    "Gen. Bus. Posting Group" := Cust."Gen. Bus. Posting Group";
    "VAT Bus. Posting Group" := Cust."VAT Bus. Posting Group";
    "Tax Area Code" := Cust."Tax Area Code";
    "Tax Liable" := Cust."Tax Liable";
    "VAT Registration No." := Cust."VAT Registration No.";
    "Shipping Advice" := Cust."Shipping Advice";
    "Responsibility Center" := UserMgt.GetRespCenter(0,Cust."Responsibility Center");
    VALIDATE("Location Code",UserMgt.GetLocation(0,Cust."Location Code","Responsibility Center"));
    
    IF "Sell-to Customer No." = xRec."Sell-to Customer No." THEN BEGIN
      IF ShippedSalesLinesExist OR ReturnReceiptExist THEN BEGIN
        TESTFIELD("VAT Bus. Posting Group",xRec."VAT Bus. Posting Group");
        TESTFIELD("Gen. Bus. Posting Group",xRec."Gen. Bus. Posting Group");
      END;
    END;
    
    "Sell-to IC Partner Code" := Cust."IC Partner Code";
    "Send IC Document" := ("Sell-to IC Partner Code" <> '') AND ("IC Direction" = "IC Direction"::Outgoing);
    
    IF Cust."Bill-to Customer No." <> '' THEN
      VALIDATE("Bill-to Customer No.",Cust."Bill-to Customer No.")
    ELSE BEGIN
      IF "Bill-to Customer No." = "Sell-to Customer No." THEN
        SkipBillToContact := TRUE;
      VALIDATE("Bill-to Customer No.","Sell-to Customer No.");
      SkipBillToContact := FALSE;
    END;
    VALIDATE("Ship-to Code",'');
    
    IF "Sell-to IC Partner Code" = '' THEN
      TESTFIELD("Bill-to IC Partner Code",'')
    ELSE
      TESTFIELD("Bill-to IC Partner Code");
    
    GetShippingTime(FIELDNO("Sell-to Customer No."));
    
    IF (xRec."Sell-to Customer No." <> "Sell-to Customer No.") OR
       (xRec."Currency Code" <> "Currency Code") OR
       (xRec."Gen. Bus. Posting Group" <> "Gen. Bus. Posting Group") OR
       (xRec."VAT Bus. Posting Group" <> "VAT Bus. Posting Group")
    THEN
      RecreateSalesLines(FIELDCAPTION("Sell-to Customer No."));
    
    IF NOT SkipSellToContact THEN
      UpdateSellToCont("Sell-to Customer No.");
    
  • SogSog Member Posts: 1,023
    there is a commit missing in the code (since no customisation is done on the table, I presume the problem lay's in the form)
    Anyways, the reason for this that a write transaction has not been finished before you try to edit the customer.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • vikram7_dabasvikram7_dabas Member Posts: 611
    Its not validating on only 1 customer no. and to other sell to customer no. its validating without any error.
    Vikram Dabas
    Navision Technical Consultant
  • vikram7_dabasvikram7_dabas Member Posts: 611
    any customer
    Vikram Dabas
    Navision Technical Consultant
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Its not validating on only 1 customer no. and to other sell to customer no. its validating without any error.

    i didnt get this?
    :-k
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    @ vikram7_dabas : Can you use the debugger and process for the customer, the error pops up for.
    where does the error pops up.... I mean the code.
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • MBergerMBerger Member Posts: 413
    From experience, these things occur when there is a customization at a wrong place in the code, that interferes with the Credit limit warning. To see if this is the problem, try turning of the credit limit warning for the customer, and see if the error still occurs. At least then you know what is wrong, the customization that is causing this will still have to be found and moved though.
Sign In or Register to comment.