Positive must be equal to 'Yes' in Cust. Ledger Entry: Entry No.=0. Current value is 'No'.
omyvadiya
Member Posts: 124
Hi,
In the Sales Invoice, i am automatically creating lines of a G/L Account on the click of a button. After the autocreation of the lines. The issue is when i post the invoice, i get the following error:
Microsoft Dynamics NAV
Positive must be equal to 'Yes' in Cust. Ledger Entry: Entry No.=0. Current value is 'No'.
OK
But if create the line manually and post i get No error, the invoice is successfully posted.
G/L creation function:
IF "Redemption Button Check" = FALSE THEN BEGIN
SLLoyaltyLocal.RESET;
SLLoyaltyLocal.SETRANGE("Document No.","No.");
SLLoyaltyLocal.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal.FINDLAST THEN BEGIN
SLLoyaltyLocal.INIT;
IF SLLoyaltyLocal."Line No." = 0 THEN
SLLoyaltyLocal."Line No." := 10000
ELSE
SLLoyaltyLocal."Line No." := SLLoyaltyLocal."Line No." + 10000;
SLLoyaltyLocal."Document Type" := SLLoyaltyLocal."Document Type"::Invoice;
SLLoyaltyLocal.Type := SLLoyaltyLocal.Type::"G/L Account";
SLLoyaltyLocal."Document No." := "No.";
SLLoyaltyLocal.VALIDATE("No.",'150223');
SLLoyaltyLocal.Quantity := 1;
SLLoyaltyLocal."Qty. to Ship" := 1;
SLLoyaltyLocal."Qty. to Invoice" := 1;
SLLoyaltyLocal."Unit Price" := "Awarded Loyalty Points";
SLLoyaltyLocal."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal.INSERT;
END;
SLLoyaltyLocal1.RESET;
SLLoyaltyLocal1.SETRANGE("Document No.","No.");
SLLoyaltyLocal1.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal1.FINDLAST THEN BEGIN
SLLoyaltyLocal1.INIT;
IF SLLoyaltyLocal1."Line No." = 0 THEN
SLLoyaltyLocal1."Line No." := 10000
ELSE
SLLoyaltyLocal1."Line No." := SLLoyaltyLocal1."Line No." + 10000;
SLLoyaltyLocal1."Document Type" := SLLoyaltyLocal1."Document Type"::Invoice;
SLLoyaltyLocal1.Type := SLLoyaltyLocal1.Type::"G/L Account";
SLLoyaltyLocal1."Document No." := "No.";
SLLoyaltyLocal1.VALIDATE("No.",'225420');
SLLoyaltyLocal1.Quantity := 1;
SLLoyaltyLocal1."Qty. to Ship" := 1;
SLLoyaltyLocal1."Qty. to Invoice" := 1;
SLLoyaltyLocal1."Unit Price" := -"Awarded Loyalty Points";
SLLoyaltyLocal1."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal1.INSERT;
END;
END;
Thanks in Advance.
In the Sales Invoice, i am automatically creating lines of a G/L Account on the click of a button. After the autocreation of the lines. The issue is when i post the invoice, i get the following error:
Microsoft Dynamics NAV
Positive must be equal to 'Yes' in Cust. Ledger Entry: Entry No.=0. Current value is 'No'.
OK
But if create the line manually and post i get No error, the invoice is successfully posted.
G/L creation function:
IF "Redemption Button Check" = FALSE THEN BEGIN
SLLoyaltyLocal.RESET;
SLLoyaltyLocal.SETRANGE("Document No.","No.");
SLLoyaltyLocal.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal.FINDLAST THEN BEGIN
SLLoyaltyLocal.INIT;
IF SLLoyaltyLocal."Line No." = 0 THEN
SLLoyaltyLocal."Line No." := 10000
ELSE
SLLoyaltyLocal."Line No." := SLLoyaltyLocal."Line No." + 10000;
SLLoyaltyLocal."Document Type" := SLLoyaltyLocal."Document Type"::Invoice;
SLLoyaltyLocal.Type := SLLoyaltyLocal.Type::"G/L Account";
SLLoyaltyLocal."Document No." := "No.";
SLLoyaltyLocal.VALIDATE("No.",'150223');
SLLoyaltyLocal.Quantity := 1;
SLLoyaltyLocal."Qty. to Ship" := 1;
SLLoyaltyLocal."Qty. to Invoice" := 1;
SLLoyaltyLocal."Unit Price" := "Awarded Loyalty Points";
SLLoyaltyLocal."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal.INSERT;
END;
SLLoyaltyLocal1.RESET;
SLLoyaltyLocal1.SETRANGE("Document No.","No.");
SLLoyaltyLocal1.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal1.FINDLAST THEN BEGIN
SLLoyaltyLocal1.INIT;
IF SLLoyaltyLocal1."Line No." = 0 THEN
SLLoyaltyLocal1."Line No." := 10000
ELSE
SLLoyaltyLocal1."Line No." := SLLoyaltyLocal1."Line No." + 10000;
SLLoyaltyLocal1."Document Type" := SLLoyaltyLocal1."Document Type"::Invoice;
SLLoyaltyLocal1.Type := SLLoyaltyLocal1.Type::"G/L Account";
SLLoyaltyLocal1."Document No." := "No.";
SLLoyaltyLocal1.VALIDATE("No.",'225420');
SLLoyaltyLocal1.Quantity := 1;
SLLoyaltyLocal1."Qty. to Ship" := 1;
SLLoyaltyLocal1."Qty. to Invoice" := 1;
SLLoyaltyLocal1."Unit Price" := -"Awarded Loyalty Points";
SLLoyaltyLocal1."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal1.INSERT;
END;
END;
Thanks in Advance.
0
Answers
-
Try validate quantity and Unit Price ... all fields should be validated, but it depends on customizations.0
-
Hi @lubost -
I tried validating all the necessary fields including the Primary keys. Still the same error.
IF "Redemption Button Check" = FALSE THEN BEGIN
SLLoyaltyLocal.RESET;
SLLoyaltyLocal.SETRANGE("Document No.","No.");
SLLoyaltyLocal.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal.FINDLAST THEN BEGIN
SLLoyaltyLocal.INIT;
SLLoyaltyLocal.VALIDATE("Document Type",SLLoyaltyLocal."Document Type"::Invoice);
SLLoyaltyLocal.VALIDATE("Document No.","No.");
IF SLLoyaltyLocal."Line No." = 0 THEN
SLLoyaltyLocal.VALIDATE("Line No.",10000)
ELSE
SLLoyaltyLocal.VALIDATE("Line No.",SLLoyaltyLocal."Line No." + 10000);
SLLoyaltyLocal.Type := SLLoyaltyLocal.Type::"G/L Account";
SLLoyaltyLocal.VALIDATE("No.",'150223');
SLLoyaltyLocal.VALIDATE(Quantity,1);
SLLoyaltyLocal.VALIDATE("Unit Price","Awarded Loyalty Points");
SLLoyaltyLocal."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal.INSERT;
END;
SLLoyaltyLocal1.RESET;
SLLoyaltyLocal1.SETRANGE("Document No.","No.");
SLLoyaltyLocal1.SETRANGE("Document Type","Document Type"::Invoice);
IF SLLoyaltyLocal1.FINDLAST THEN BEGIN
SLLoyaltyLocal1.INIT;
SLLoyaltyLocal1.VALIDATE("Document Type",SLLoyaltyLocal1."Document Type"::Invoice);
SLLoyaltyLocal1.VALIDATE("Document No.","No.");
IF SLLoyaltyLocal1."Line No." = 0 THEN
SLLoyaltyLocal1.VALIDATE("Line No.",10000)
ELSE
SLLoyaltyLocal1.VALIDATE("Line No.",SLLoyaltyLocal1."Line No." + 10000);
SLLoyaltyLocal1.Type := SLLoyaltyLocal1.Type::"G/L Account";
SLLoyaltyLocal1.VALIDATE("No.",'225420');
SLLoyaltyLocal1.VALIDATE(Quantity,1);
SLLoyaltyLocal1.VALIDATE("Unit Price","Awarded Loyalty Points");
SLLoyaltyLocal1."Uneditable GL Lines" := TRUE;
SLLoyaltyLocal1.INSERT;
END;
END;
NO LUCK .0 -
Try Statistics button - Amount including VAT should be greater then 0.
-
Compare lines created manually to lines created by code and find differences.
0 -
I compared lines and tried, but no luck.
The G/l Lines created automatically are for awarding points to customers, so the points/amount lines must be created in cust. ledger entry.I checked in the demo database, there are no extra lines created for those -ve amt lines.
the amt is deducted from actual amount.
Thanks in advance.0 -
There is probably a customization behind the sales line table and/or posting routine. In standard NAV - if data are the same, result must be same.0
-
Hi, I got it,
There is a parameter TransactionLogEntryNo that was going as blank as the code was commented of it, i don't know why, but in std it wasn't commented in cdu 80.
If i uncomment it, i get a new error:
Microsoft Dynamics NAV
The Microsoft Dynamics ERP Payment Services Setup does not exist. Identification fields and values: Primary Key=''
OK
Any idea how can i inactive the setup, as my Payment service setup0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 333 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