Friday, November 2, 2018

SFTP Management using WinSCP

👋 Hi all,
SFTP Management using WinSCP
Recently I have worked on a Website Integration where the requirement was to upload, download, Remove, & Move the files over SFTP and then send the Information to Website Team through  REST/JSON API.

To achieve this goals I have created two modules.

1. Extract the Documents from NAV and then Upload, Download, Move & Remove over SFTP.
This module can be performed by SFTP Management Codeunit using WinSCP tools.

2. Send the information to Website so that they can manage (CRUD Operation) their database.
This module can be performed by Website Integration Mgt. Codeunit (Coming Soon).

WinSCP
WinSCP is an open source free SFTP client, FTP client, WebDAV client, S3 client and SCP client for Windows. Its main function is file transfer between a local and a remote computer. Beyond this, WinSCP offers scripting and basic file manager functionality.

Module 1:
Extract the Documents from NAV and then Upload, Download, Move & Remove over SFTP. This module can be performed by SFTP Management Codeunit using WinSCP tools.
Assume in NAV we have below objects




For better understanding please see the below Table structures:

Table 50065 Document Setup


Table 50066 Document Category



Table 50067 Documents


Plan:
1. First of all I would like to extract the documents from NAV, To achieve this I have written a procedure namely [TryFunction] ExportDocument(DocNoP : Code[20])

2. Now Upload the Extracted document into SFTP.
To achieve this I have written a procedure namely
 [TryFunction] UploadFile(SourceFileP : Text)

3. To maintain history and sending data to website I have done some more work Like:

a. I have setup, if document is Create / Update / Delete in NAV then create a record in Send Items to Website Table with
SendItemstoWebsite."Process Status"::Pending
And once the document is uploaded in SFTP then SendItemstoWebsite."Process Status"::” “ should blank.

b. Now the second module is going to execute for sending the data to website using REST / JSON API.

4. To perform this you have to install WinSCP in server and copy the WinSCPnet.dll file  from installed directory (C:\Program Files (x86)\WinSCP) and paste into NAV Service Add-Ins folder like: C:\Program Files\Microsoft Dynamics NAV\90\Service\Add-ins

Development:
Create a codeunit and declare the global variables as shown in below screenshot.



Create functions as shown as below screenshots



























Please let me know if you have any queries.....




Thursday, June 21, 2018

Document Management in Microsoft Dynamics NAV


Document Management in Microsoft Dynamics NAV
Overview:-
Document management is a way to Capture and store any type of files in MS Dynamics Nav. It supports for both incoming and outgoing means we can store the document we can export the document anywhere from NAV.
Advantages of Document management:-
·         We can import various types (Image/doc) of document in NAV.
·         Can view the document within NAV even delete if from your folder can view from Nav.
·         Can take print of document with in NAV.
·         Can send the Document.
·         We can export the document from NAV.
·         We can edit (Word / Excel) type of documents from NAV.
What we need
1.      We need 11 customized objects which are shown in below image:-




2.      Below are the fields required in Document setup:-




3.      Code unit for document management is specified Below :-

















          











How it works:-
1.      We can add this document management in any page where we need the document should be attached for example:-
I am showing here an action of document in Customer page for this we need to write below code in action of customer page :-



2.      Now Open the client And go as per below path and have to setup a path to store the documents:-




3.      Now open the customer page and click on the document



4.       



5.    

6.    

      

7.



Tuesday, October 10, 2017

How to display sum value in factbox on base of multiple line selection

How to display sum value in factbox on base of multiple line selection
Typical issue is to show a calculated value in a factbox on base of the currently selected line in a list page or the lines in a subpage. Is it possible to get a calculated value on base of more than one selected line? Let’s check out.
Let’s say we want to display the sum of field “Credit Limit” in the customer list when selecting multiple lines. So first we edit page 9082 “Customer Statistics FactBox”. There we add a global variable SumCredLimit (decimal) to the page, then we add a new line in page with sourceexpr = SumCredLimit.




Now we add a new global function SetSumCredLimit.



Save and close the page. Now we edit page 22 customer list. There we rename page part “Customer Statistics FactBox” to CustStatFbx. That’s needed, so that we can reach the custom functions in page “Customer Statistics FactBox” from page “customer list”.



After that edit the page code (F9). Goto trigger OnAfterGetCurrRecord, there add local variable Cust (record|Customer). Add following code to trigger:



Save and close the page. Now run the Nav windows client and goto customer list.
The result:


Reference: jonthan




Popular Posts