I created vLogic to be a useful tool in a variety of situations. It allows for customization without the overhead of a full-blown .NET DLL. A lot of people think vLogic is a good idea, but I’m not aware of it being use in any real capacity. As we all know, there is sometimes a big gap between “good idea” and “useful”. So I though I would spend a few posts taking a crack at some real-word problems using vLogic.
This week’s post will be addressing an entry on the Vault Idea Exchange. A user wants to “Have a category automatically assigned to a document, based on the folder it is 'imported' to. This would work only when there is a new document, or not another category, assigned to the document.”
Yes, I think I can do that with vLogic.
Vault Workgroup/Collaboration/Professional 2013 and vLogic 2013
- Install vLogic if not installed already.
- Download the AddFilePost.SetToParentCategory.ps1 script and put it in the vLogic’s “Event Scripts” folder. The folder can be found at %ProgramData%\Autodesk\Vault 2013\Extensions\vLogic\Event Scripts with Windows Explorer.
- If “Base” is not your default file category, open up the .ps1 script and edit the value for $BaseCategory.
- Start or restart Vault Explorer.
- Set up File and Folder categories with matching names for cases where you want the script to run. This step is needed because categories can’t be shared across Files and Folders.
- Set a folder category and add a file to it through Vault Explorer. If the file goes into the default category, the vLogic script will assign it to the file category with the same name as the folder’s category.
- The script only works for files added through Vault Explorer.
- This script can only run on clients with vLogic and the .ps1 file. Project Thunderdome can be used to deploy them both to multiple clients.
Here is the source code. As you can see, there is not a lot of code needed here.
# This script updates new files not assigned a category are updated to match the category on the parent folder.