Hi guys,
am using the latest version of SQL.
I have written some codes in which i am inserting records in the table Change Log Entry.
On the form i have given insert permissions.
But i get a message like:
1088,"42000", [Licrosoft][ODBC SQL Server Driver][SQL Server] Object XXX.dbo.Cronus$Change Log Entry" cannot be found, as it doesn't exist or u do not have sufficient permissions .
SQL:
SET IDENTITY_INSERT "XXX.dbo.Cronus$Change Log Entry" ON
The same codes work fine in standard nav.
Can you pls help.
0
Comments
See http://www.mibuso.com/forum/viewtopic.php?f=23&t=18411&hilit=SET+IDENTITY
Also have a look at codeunit 423 "Change Log Management", function InsertLogEntry to see how Navision does this.
IF NOT CONFIRM(Text001,FALSE,"Statement No.") THEN
EXIT
ELSE
BEGIN
IF ChangeLogEntry.FINDLAST THEN
LastEntryNum := ChangeLogEntry."Entry No.";
BankAccLedEntry.SETRANGE("Statement No.","Statement No.");
IF BankAccLedEntry.FINDSET(TRUE,TRUE) THEN
REPEAT
BankAccLedEntry.Open := TRUE;
BankAccLedEntry.MODIFY;
ChangeLogEntry.INIT;
ChangeLogEntry."Entry No." := LastEntryNum + 1;
ChangeLogEntry."Date and Time" := CURRENTDATETIME;
ChangeLogEntry."User ID" := USERID;
ChangeLogEntry.Time:=TIME;
ChangeLogEntry."Table No." := 271;
ChangeLogEntry."Primary Key" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.");
ChangeLogEntry."Field No.":= 36;
ChangeLogEntry."Type of Change" := ChangeLogEntry."Type of Change"::Modification;
ChangeLogEntry."Old Value" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.") + ' ' + 'False';
ChangeLogEntry."New Value" := 'N° de séquence:'+ FORMAT(BankAccLedEntry."Entry No.") + ' ' + 'True';
ChangeLogEntry.INSERT;
LastEntryNum += 1;
UNTIL BankAccLedEntry.NEXT = 0;
MESSAGE(Text002);
END;
But you better use the existing functions in the ChangeLog codeunit to update that table, instead of inserting the records yourself. Have a look at Change Log for records modified with a codeunit how it's done.
.INIT is not clearing primary key. You need to assign 0 to the field (it means not remove the line but change it to
but you already knows that if you have used the search functionality... ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!