The filename already changes when the document name is changed but I need the document name to change when the document name is changed.
I assume I'll need to create a custom module with a post trigger on the Doc code written in C++ and register the module. Then add the dll to everyone's PWE.
Looking for guidance here as I normally write external programs in VB.NET.
It isn't clear to me what exactly you are trying to do. What do you mean by "..I need the document name to change when the document name is changed."?
As I like to say, "words get in the way". I think you mean HOOK when you say "trigger". And yes, you set hooks by the use of a custom module.
I suspect that you are asking about a way to keep the document's name and the document's filename in sync when the document's "Document Code" is changed.
I would suggest that you take a look at my "HookWatcher" tool and walk through the steps you want to automate to see what hooks are available for each part of the process. I suspect that if you are updating the document's "Document Code', that it will "fire" AAHOOK_UPDATE_LINK_DATA, and with a post hook (success), you could then examine the document's name and file name to see if they match the "PlaceHolder" part of the Document Code and then change the document's name and filename to match.
But I'm just guessing on what you want to do.
And along with more details on what you are trying to accomplish, it is always helpful to specify what version of ProjectWise you are using, including the version of the PW SDK.
You are correct, I want the Document Code post hook success to sync the Document Name and Filename.PWE 10.00.03.280, PW SDK 2018
I've been trying to piece all of this together but there's just too many parts.
Does anyone have a working example they can share?
Interesting request. I've been intending to create a C# sample custom module to show how to implement hooking with C# using MostOfDavesClasses. I'll try to do this soon and I will try the approach of creating a post hook (success) when the attributes are changed for a document. So I'm thinking that on the post hook success, I'll look to see if there is an attribute for the "place holder", and if there is one, I'll compare its contents to the document's name and if it is different, I'll try to rename the document.
I probably won't be able to get this done for a while, but I'll work on it.
Thanks for the idea!
Struggling to work with C++.
I have a filename but how do I get the extension from this filename?
Then how do I add this extension to another string to concatenate the two together?
Google or Bing (or other search engine?) is your "best friend" for questions like this. Try entering text similar to the following into your favorite search engine:
site:microsoft.com c++ get file extension
The function I typically use to get the parts of a file's device, path, name, and extension is a one of the variations of "splitpath()".
The ProjectWise SDK includes some "File System Handling Functions" including variations of aaApi_SplitPath(). Note that the first two variations have been deprecated, so use aaApi_SplitPath3() as it can handle multiple dot extensions.
As for how to concatenate two strings, well there are various methods. I tend to use Microsoft's MFC framework, which has the CString class, but you can also do it the "C" way, or use one of the various methods that you can find with a search for "C++ concatenate strings".
You might consider looking into some online training for C++ as there is much available, and a lot of it is free.
When I modify the Document Name it doesn't change in ProjectWise Explorer until a refresh. Is there a function to refresh the list of documents?