Sunday, March 17, 2019

Transaction No. Update in Ledger and Posted Transnational Tables in Dynamics NAV

Hello Friends,

When we create new G/L Entry manual in 17 G/L Entry table than most of time we forgot to set Transaction No. to max value + 1 in new inserted entry.

When system post any new G/L Entry, It has take transaction no.from last entry and increment by 1 to create new entry.

So, if result is that Transaction No. start duplicate values and it cause issue some reports and reverse transaction.

So, i have create batch process to correct unique incremental value in posted entries.

Identify the G/L Entry number from where the system start creating duplicate transaction number.

Now the following batch process correct data, 

Sample Code

//17
GL_lRec.RESET;
GL_lRec.SETRANGE("Posting Date","Posting Date");
GL_lRec.SETRANGE("Document No.","Document No.");
IF GL_lRec.FINDSET THEN BEGIN
  REPEAT
    IF GL_lRec."Transaction No." = OldTranscationNo_gInt  THEN BEGIN
      GL_lRec."Transaction No." := NewTranscationNo_gInt;
      GL_lRec.MODIFY;
    END;
  UNTIL GL_lRec.NEXT = 0;
END;

Download the batchjob object from attached link:
https://1drv.ms/u/s!An8nhANnLJmtkBgLpHo4bTcvA4pS

Let me know if you have any query
Thank you for reading

Keep Sharing..Keep Growing...

Merge Object Using Powershell (CU Update & NAV Upgrade)

Hello Friends,

Use the NAV Development Shell to auto merge the NAV Objects

It is very useful for

  • CU Upgrade
  • NAV Upgrade
  • Bug Fix Merge
  • Big/Small Functionality Merge
Suppose we take one example to install CU 17 to customer object having CU11

1) Create 4 Folder as shown in following snapshot.
















2) Open NAV Development Shell using administrator and following script

Cmdlet: Merge-NAVApplicationObject -OriginalPath C:\Users\nishit\Desktop\Temp\Shyam\1Original\*.txt -ModifiedPath  C:\Users\nishit\Desktop\Temp\Shyam\2Modified\*.txt -TargetPath C:\Users\nishit\Desktop\Temp\Shyam\3Target\*.txt -ResultPath C:\Users\nishit\Desktop\Temp\Shyam\4Result\
3) System auto merge targe file and show the result, You need to solve conflict files





































Done.

If you have query than write comments
Thank you for reading.

Keep Sharing..Keep Growing...

DataMatrix Code Print from Microsoft Dynamics NAV

Hello Friends,

Now you can easily generate DataMatrix Code (like QR Code) from Microsoft Dynamics NAV


Sample DataMatrix Output:




















Sample of Dynamics NAV Code

      FileNameBmp := FileManagement.ServerTempFileName('bmp');
      DataMatrix := DataMatrix.DmtxImageEncoder;
      Image := DataMatrix.EncodeImage(Text2Encode);
      Bitmap := Bitmap.Bitmap(Image, pxWidth, pxHeight);
      Bitmap.Save(FileNameBmp);

      CLEAR(TempBlob);
      IF TempBlob.INSERT THEN;
      FileManagement.BLOBImportFromServerFile(TempBlob, FileNameBmp);
      TempBlob.MODIFY;


Copy DLL File in Add-ins Folder
















Download the sample object from attached link
https://1drv.ms/u/s!An8nhANnLJmtkBaBKCwFT_VX00NR

Write the comments if need more detail
Thank you for reading.
Keep Sharing...Keep Growing.

Modify Field value using RecordRef & FieldRef

Hello Friends,

You can modify any table field value using RecordRef and FieldRef

A RecordRef object references a record in a table. Typically, you use a RecordRef object in functions that must apply to more than one table, not to a specific table. For example, you could use a RecordRef object in a function that loops through several tables or as a parameter of a function that is called for records of different tables.
The RecordRef object can refer to any table in the database. Use the OPEN Function (RecordRef) to use the table number to select the table that you want to access, or use the GETTABLE Function (RecordRef) to use another record variable to select the table that you want to access.
If one RecordRef variable is assigned to another RecordRef variable, then they both refer to the same table instance.
Example of code to modify field value using record ref & field ref variable
********** Sample Code to Modify Record using Record Reference and Modify the field value using Field Ref *************************

IF STRPOS(FORMAT(ApprovalEntry."Record ID to Approve"),'Gen. Journal Line') <> 0 THEN BEGIN
  RecRef_lRecRef.GET(ApprovalEntry."Record ID to Approve");
  FieldRef_lFrf := RecRef_lRecRef.FIELD(50084);
  FieldRef_lFrf.VALUE(TRUE);
  RecRef_lRecRef.MODIFY;
  RecRef_lRecRef.CLOSE;
END;

// ApprovalEntry."Record ID to Approve" à Record ID field and contain value like ('Gen. Journal Line :Default,Default,10000')

Name
DataType
Subtype
Length
RecRef_lRecRef  
RecordRef  

FieldRef_lFrf       
FieldRef