How to check if a doc is open...

xhostar
Member Posts: 2
Hello all:
I have a question... :?:
I need to know if a document is being opened at this moment, so, if another user try to open it, can show a message like: "This document is in use, try later...".
I have a table named "Documents". Each record is a physical document in my pc:
This is the situation:
* I open a document (word,excel... any other) from within Nav.
* Just before open it, mark as TRUE a boolean field named "In Use".
* If another user try to open the same doc, if "In Use" is true, the message "This doc. is being used...." appears.
* When the first user close the application, Navision change the field "In Use" to FALSE.
This is my code:
This code runs ok but there is a problem. Because bWaitOnReturn is TRUE, Navision hopes the application ends, and then, the user cannot work in any other form.
Thanks.
I have a question... :?:
I need to know if a document is being opened at this moment, so, if another user try to open it, can show a message like: "This document is in use, try later...".
I have a table named "Documents". Each record is a physical document in my pc:
This is the situation:
* I open a document (word,excel... any other) from within Nav.
* Just before open it, mark as TRUE a boolean field named "In Use".
* If another user try to open the same doc, if "In Use" is true, the message "This doc. is being used...." appears.
* When the first user close the application, Navision change the field "In Use" to FALSE.
This is my code:
VARS WSHShell Automation 'Windows Script Host Object Model'.WshShell AppExe Text WinStyle Variant bWaitOnReturn Boolean CODE IF RecDoc.InUse = TRUE THEN ERROR('The document %1 is being used...',RecDoc.Name); IF ISCLEAR(WSHShell) THEN CREATE(WSHShell); AppExe := '"C:\MyExeProgram.exe " "' + RecDoc.Name + "'; WinStyle := 1; bWaitOnReturn := TRUE; RecDoc.InUse := TRUE; RecDoc.MODIFY; WSHShell.Run(AppExe,WinStyle,bWaitOnReturn); RecDoc.InUse := FALSE; RecDoc.MODIFY;
This code runs ok but there is a problem. Because bWaitOnReturn is TRUE, Navision hopes the application ends, and then, the user cannot work in any other form.
Thanks.
0
Comments
-
That's why Navision (or Microsoft) created something like the WordHandler and the "wrdHandler.WaitForDocument" (search in codeunit 5054).
You'll have to be quite inventive to solve this one. Look at this post:
http://www.mibuso.com/forum/viewtopic.php?t=14282&highlight=client1.
May be this quote from Ara3n:How about try to copy the executable from that location to a temp location and delete the executable and copy it back if you succeed.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