GetWorkingFolder return wrong path

GetWorkingFolder return wrong path

stefan.palm
Advocate Advocate
3,956 Views
10 Replies
Message 1 of 11

GetWorkingFolder return wrong path

stefan.palm
Advocate
Advocate

In Vault 2018 the row below return wrong path.

I have in vault options set enforce working folder to "C:\Vault_WF" but the code below returns "C:\Users\[USERNAME]\Documents\Vault"

 

Connection.WorkingFoldersManager.GetWorkingFolder("$").FullPath

 

Also i get same problem when using 

Connection.WorkingFoldersManager.GetPathOfFileInWorkingFolder(file).FullPath

 

 

Anyone have the same problem? This issue came with vault 2018.

0 Likes
Accepted solutions (1)
3,957 Views
10 Replies
Replies (10)
Message 2 of 11

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @stefan.palm,

 

I tested the below scenario and I did not face an issue (on Vault 2018.1 ). It returns the correct folder that has been enforced.

 

In addition, I changed the enforced working folder in Vault options, while my code was active. The Connection.WorkingFoldersManager.GetWorkingFolder("$").FullPath returned my old working folder path, until I restarted my Vault Explorer. After restarting the Vault Explorer the new working folder path was correctly fetched.

 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 3 of 11

stefan.palm
Advocate
Advocate

I installed Vault 2018.2 today, still same issue. It returns wrong workfolder path. I have had this issue at some customer installations since release 2018. Se uploaded screen dump.

0 Likes
Message 4 of 11

Markus.Koechl
Autodesk
Autodesk

I am able to reproduce as it is the expected behavior.

To get an enforced working folder you need to apply another method:

#GetWorkingFolder will return the virtual path (set in Details of the folder); if no mapping in details the default will returned
				$wf = $vaultConnection.WorkingFoldersManager.GetWorkingFolder("$").FullPath
				#if working folder location is enforced the GetRequiredWorkingFolderLocation method returns it.
				If($vault.DocumentService.GetEnforceWorkingFolder() -eq $true) {
					$wfEnf = $vault.DocumentService.GetRequiredWorkingFolderLocation()
				}

It is documented in the SetEnforceWorkingFolder() method. I agree that another hint in the documentation of the method that you tried could be helpful.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 11

stefan.palm
Advocate
Advocate

You mean the function should not return the local disc work folder path of the vault folder path? Should i build the path with my own code combining the return path from "GetRequiredWorkingFolderLocation" and the current vault folder path? What if GetEnforceWorkingFolder is false, how do i get the correct work folder then?

 

Look at the attached screendump, i try to get the work folder path of the Vault folder path "$/Designs" and get "C:\Users\Palm\Documents\Vault\Designs" instead of the correct one which should be "C:\Vault_WF\Designs", is that the correct behavior of the function?

0 Likes
Message 6 of 11

Markus.Koechl
Autodesk
Autodesk

Let me put this into this way: you need to differentiate first; is EnforceWorking folder true or false. 

If true - (this is your scenario, right?) then you need to use the DocumentService.GetRequiredWorkingFolderLocation() method.

If false - then leverage one of the overloads of WorkingFoldersManager.GetWorkingFolder(). These methods return other than default values only, if you set a vault folders local path explicitly to another location. To do this, right click on a folder and apply an individual local path to it. Once you set an individual path, the method GetWorkingFolder will return this correctly.

 

So for your objective, query the Option EnforceWorkingFolder first an then proceed:

If($vault.DocumentService.GetEnforceWorkingFolder() -eq $true) {
					$wfEnf = $vault.DocumentService.GetRequiredWorkingFolderLocation()
				}

 

Hope this clarifies.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 7 of 11

stefan.palm
Advocate
Advocate

I get wrong path either EnforceWorking folder is set to true or false, does not matter. Also it does not matter if i set work folder manually, still get wrong path. In Vault 2016 i get the correct path using the same code, EnforceWorking set to true or false does not matter, in 2016 i always get the correct work folder path using only the method WorkingFoldersManager.GetWorkingFolder(VaultFolderPath).

0 Likes
Message 8 of 11

Markus.Koechl
Autodesk
Autodesk
Do you get the expected path using DocumentService.GetRequiredWorkingFolderLocation()?
I fear we are not on the same page...
1) If the EnforceWorkingfolder = True then you have to use the method DocumentService.GetRequiredWorkingFolderLocation()
2) If the EnforceWorkingfolder = false then you have to use the GetWorkingFolder() method. You will get the virtual path C:\Users\[USERNAME]\Documents\Vault\. To change this, you need to configure the working folder manually: right-click the folder ($), select Details and set the working folder to c:\Vault_WF\. Once you configured the root, the method GetWorkingFolderLocation() will return the expected path on c:\.
So, your code has to differentiate based on the fact EnforceWorkingFolder true or false. If false, Vault expects dedicated configuration. If you don't configure, the default virtual path applies.


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 9 of 11

stefan.palm
Advocate
Advocate

If EnforceWorkingFolder = true i get the correct workingfolder using GetRequiredWorkingFolderLocation, but i never get the correct working folder from GetWorkingFolderLocation(vaultPath)

 

In run 1 i have EnforceWorkingFolder = true and have specified C:\Vault_WF in settings. In run 2 i have EnforceWorkingFolder = false and have specified the folder C:\Vault_WF in detalis of the vault folder "$"

 

http://autode.sk/2muYo5R

 

Note: In Vault 2016 this is not an issue for me, the function GetWorkingFolderLocation(vaultPath) always returns the correct path.

0 Likes
Message 10 of 11

Markus.Koechl
Autodesk
Autodesk

Ok. Means you are fine enforcing the folder.

I did not look into the other approach's detail as I thought you are having trouble to get the enforced working folder.

For approach #2 I am seeing an issue as well: the working folder mapping set in the configuration detail is ignored, however, set programmatically it works:

$vaultConnection.WorkingFoldersManager.SetWorkingFolder("$/", "C:\temp")
				$wf = $vaultConnection.WorkingFoldersManager.GetWorkingFolder("$/", $true)

Actually, I doubt that this behavior is intended and will check with development.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 11 of 11

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Being back with more details, I need to ask that your application is a standalone or a job or an extension.

The reason why I am asking is:

- Each application/login /connection creates or uses its individual "WorkingFolders.xml" and saves working folder mappings, which are not enforced by administrators. Compare the screenshot below and my listing.

Roaming_Autodesk_VaultCommon.jpg

1) This address is my Vault Explorer Login; I created a custom job, that retrieves working folder mappings. Vault Explorer and Jobs return the values that are configured in the Details -> Change... setting.

2) This address is the login used by my Powershell code; the direct access/login via web service. It behaves like a standalone application. As long as I don't set individual overrides, the default virtual paths ..MyDocuments\Vault\*.. are returned. As soon as the script (application) creates its overrides, the file "WorkingFolders.xml" is created and stores the individual mapping.

 

#set programmatically 
				$vaultConnection.WorkingFoldersManager.SetWorkingFolder("$", "C:\SD124422\")
				$vaultConnection.WorkingFoldersManager.SetWorkingFolder("$/Libraries", "C:\MFG124959\Libraries")

The resulting WorkingFolder.xml content:

 

 

<?xml version="1.0" encoding="utf-8"?>
<WorkingFolders xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.autodesk.com/msd/plm/WorkingFolders/2004-08-09">
  <Folder>
    <VirtualPath>$</VirtualPath>
    <PhysicalPath>C:\SD124422</PhysicalPath>
  </Folder>
  <Folder>
    <VirtualPath>$/Libraries</VirtualPath>
    <PhysicalPath>C:\MFG124959\Libraries</PhysicalPath>
  </Folder>
</WorkingFolders>

 

3) This address is a Vault Extension, that re-uses the existing user credentials, but establishes a new connection. Again - like 2) - the default virtual mapping returns, as long as this application does not apply an override to individual mappings. If so, the file "WorkingFolder.xml" is created.

 

With respect, that you probably already had a solution in 2016 release state, you need to differentiate which application/login type your current code project matches. As soon as it establishes a new/individual connection, your application needs to set the override.

 

Admitting that this is not self-explaining, I hope that the description allows reproducing and debugging each scenario to get the insight for understanding.

Thank you for pushing us elaborating these details.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes