Adding Document Links Processing Report

Excepti0nal
Member Posts: 74
Hello,
We recently did an upgrade on our system from 4.0 to 2013. We had a processing report that would update links on ledger entries to our shared network drive (N:\ drive). Can anyone tell me why this code would no longer work in 2013? Also we used to be able to manually add the links. Now when you click links, it does not provide an option to add the links in the links box. Is there somewhere else that they need to be added?
We recently did an upgrade on our system from 4.0 to 2013. We had a processing report that would update links on ledger entries to our shared network drive (N:\ drive). Can anyone tell me why this code would no longer work in 2013? Also we used to be able to manually add the links. Now when you click links, it does not provide an option to add the links in the links box. Is there somewhere else that they need to be added?
APFileLocation := 'N:\Payables\'; ARFileLocation := 'N:\Receivables\'; OnPreReport() IF GUIALLOWED THEN Window.OPEN('Processing #####################################1#####'); APFileLocation := DELCHR(APFileLocation,'>','\') + '\'; ARFileLocation := DELCHR(ARFileLocation,'>','\') + '\'; MyFile.SETRANGE(Path,APFileLocation); MyFile.SETRANGE("Is a file",TRUE); IF MyFile.FIND('-') THEN REPEAT VendorLedger.RESET; VendorLedger.SETCURRENTKEY("Document No."); VendorLedger.SETRANGE("Document No.",COPYSTR(MyFile.Name,1,STRLEN(MyFile.Name)-4)); VendorLedger.SETRANGE("Document Type",VendorLedger."Document Type"::Invoice); IF VendorLedger.FINDFIRST THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,VendorLedger."Document No."); recordLink.SETRANGE(Description,MyFile.Name); IF recordLink.ISEMPTY THEN BEGIN VendorLedger.ADDLINK(MyFile.Path+MyFile.Name,MyFile.Name); COMMIT; END; END; UNTIL MyFile.NEXT = 0; MyFile.SETRANGE(Path,ARFileLocation); MyFile.SETRANGE("Is a file",TRUE); IF MyFile.FIND('-') THEN REPEAT CustLedger.RESET; CustLedger.SETCURRENTKEY("Document No."); CustLedger.SETRANGE("Document No.",COPYSTR(MyFile.Name,1,STRLEN(MyFile.Name)-4)); CustLedger.SETRANGE("Document Type",VendorLedger."Document Type"::Invoice); IF CustLedger.FINDFIRST THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,CustLedger."Document No."); recordLink.SETRANGE(Description,MyFile.Name); IF recordLink.ISEMPTY THEN BEGIN CustLedger.ADDLINK(MyFile.Path+MyFile.Name,MyFile.Name); COMMIT; END; END; UNTIL MyFile.NEXT = 0; IF GUIALLOWED THEN Window.CLOSE;
0
Answers
-
This issue was fixed with the code changes below. Thank you ara3n! Also to add new links to documents on the vendor ledger entry, it cannot be added from the links button on the ribbon. If you show the links factbox, you can add new links from there.
OnInitReport() APFileLocation := 'N:\Payables\'; ARFileLocation := 'N:\Receivables\'; OnPreReport() IF GUIALLOWED THEN Window.OPEN('Processing #########################1#'); APFileLocation := DELCHR(APFileLocation,'>','\') + '\'; ARFileLocation := DELCHR(ARFileLocation,'>','\') + '\'; VendorLedger.RESET; VendorLedger.SETCURRENTKEY("Document No."); VendorLedger.SETRANGE("Posting Date", CALCDATE('-5M',TODAY),TODAY); VendorLedger.SETRANGE("Document Type",VendorLedger."Document Type"::Invoice); IF VendorLedger.FINDSET THEN REPEAT IF NOT VendorLedger.HASLINKS THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,VendorLedger."Document No."); IF ClientFileHelper.Exists(APFileLocation + VendorLedger."Document No." + '.PDF') OR ClientFileHelper.Exists(APFileLocation + VendorLedger."Document No." + '.pdf') THEN BEGIN VendorLedger.ADDLINK(APFileLocation + VendorLedger."Document No." + '.PDF' ,VendorLedger."Document No." + '.PDF'); COMMIT; END; END; UNTIL VendorLedger.NEXT = 0; CustLedger.RESET; CustLedger.SETCURRENTKEY("Document No."); CustLedger.SETRANGE("Posting Date", CALCDATE('-5M',TODAY),TODAY); CustLedger.SETRANGE("Document Type",CustLedger."Document Type"::Invoice); IF CustLedger.FINDFIRST THEN REPEAT IF NOT CustLedger.HASLINKS THEN BEGIN IF GUIALLOWED THEN Window.UPDATE(1,CustLedger."Document No."); IF ClientFileHelper.Exists(ARFileLocation + CustLedger."Document No." + '.PDF') OR ClientFileHelper.Exists(ARFileLocation + CustLedger."Document No." + '.pdf') THEN BEGIN CustLedger.ADDLINK(ARFileLocation + CustLedger."Document No." + '.PDF' ,CustLedger."Document No." + '.PDF'); COMMIT; END; END; UNTIL CustLedger.NEXT = 0; IF GUIALLOWED THEN Window.CLOSE; OnPostReport()
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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