Browse a "network" folder and import files (pictures) - NAV 2016

madsmorre
Member Posts: 40
Hi
First - i'm not all that familiar with the 3-tier yet and therefor I struggle a little on different development issues.
One thing i'm working on (and struggeling with) at the moment is how to do the following
We have a lot of items (fashion clothes) and needs to attach pictures in NAV to these. In the old NAV (2-tier) I used the Filerec table to browse a folder - filtered on only files with certain characteristics (.jpg and with a special naming so I knew which item to import to). If I found any files I would import them one by one to the correct Item.
How to browse a folder on either the network or locally on the client?
Hope to hear from you.
Regards
Mads Morre
First - i'm not all that familiar with the 3-tier yet and therefor I struggle a little on different development issues.
One thing i'm working on (and struggeling with) at the moment is how to do the following
We have a lot of items (fashion clothes) and needs to attach pictures in NAV to these. In the old NAV (2-tier) I used the Filerec table to browse a folder - filtered on only files with certain characteristics (.jpg and with a special naming so I knew which item to import to). If I found any files I would import them one by one to the correct Item.
How to browse a folder on either the network or locally on the client?
Hope to hear from you.
Regards
Mads Morre
0
Best Answer
-
Slawek - your the man!
I succeded in reading the files in the folder on my client side by using your code and coding tips !!
I'm now working on importing them and then move the file to a "processed" folder, but I will try and figure this out.
Thanks a lot for your input. I'm sure taht i will get more familiar with the 3-tier solution by working with it.
Best Regards
Mads Morre1
Answers
-
This is one of possible ways of addressing your problem:
SysObj := SysDir.GetFiles(FolderPath); SysList := SysList.List; SysList.AddRange(SysObj); FOR i := 1 TO SysList.Count DO BEGIN CurrentFile := FORMAT(SysList.Item(i-1)); //rest of your code END
The variables are
SysObj : System.Object.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SysDir : System.IO.Directory.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SysList : System.Collections.Generic.List`1.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
Hi Slawek
I'm not able to create/find the specified Globals.
I can create them as DotNet but I can't find the exact Variables your are specifying.
Regards
Mads Morre0 -
All three are DotNet variables. You should be able to define var name, then type (DotNet), and then paste the subtype from what I've posted.
If you want to find and define them 'from scratch' please use the assembly : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I can create my variables now.
What kind of variabel is CurrentFile? Is that the actual file - if I need to do something with it (import it to an item).
Mads Morre0 -
CurrentFile is text, on each loop turn it will hold a full path to a file found in the FolderPath locationSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Hi
I managed to get the code working, but the folder I specify, seems to be from the Serverside. If I ex. Writes 'C:\temp\' it looks at the server - not on my client.
It is a little more complicated because we haven't got any real network folders - we operate totally in Office365.
I think that I have found the network path (UNC-path) to my Office365 - but if this isn't useable, we can copy the files to a folder on my local machine and import from there.
If the UNC-path to Office365 should be useable, it should def. seeing from (my) client side.
It is prob. me who doesn't understand fully the 3-tier solution.
/Mads Morre0 -
This is how the NAV work these days
. The code is executed by the NST on the server and everyting is seen from the NST point of view. NAV RTC client is just an UI frontend, it does not do any real work.
If you want to browse the folders on client side (as visible from user PC) you can try to edit the properties on all three DotNET variables and mark them as RunOnClient = Yes
You will also have to add a line of code uploading the file to the server before processiing it:FOR i := 1 TO SysList.Count DO BEGIN CurrentClientFile := FORMAT(SysList.Item(i-1)); ServerFileName := C419.UploadFileSilent(CurrentClientFile); // rest of your code processing the ServerFileName // and deleting the ServerFileName afterwards END
(C419 is a variable of type codeunit 419)
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Slawek - your the man!
I succeded in reading the files in the folder on my client side by using your code and coding tips !!
I'm now working on importing them and then move the file to a "processed" folder, but I will try and figure this out.
Thanks a lot for your input. I'm sure taht i will get more familiar with the 3-tier solution by working with it.
Best Regards
Mads Morre1 -
If you are interested I made a function to browse folder contents. It indexes thousand of files in seconds. I use it to get modified dates and so, when doing incremental updates.
Maybe you can use it.
https://juhl.blog/2017/07/05/get-filelist-using-net/Follow me on my blog juhl.blog1 -
Thank you, Juhl
This looks interesting. I will use the Temp-table solution to present the data to the users before importing the pictures to the items.0 -
I Know this Post is already pretty old, but you guys should have a look at Codeunit 419. - It's specificly made to help you handle File Exchange between Server and Client.0
-
Hello,
I want to execute code in the worker thread of Dynamics nav , so the RunOnClient property should be set to "No." Is there another method with the RunOnClient property set to "No"?
Best regards,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