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.
0
Answers
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 .
Compare lines created manually to lines created by code and find differences.
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.
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 setup