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.
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
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
See if setting a post hook on AAHOOK_CODE_GENERATION_DLG is what you need. I suspect that this hook only "fires" if you are using the Document Code Dialog.
If you are setting the Document Code via API functions,then I suspect that AAHOOK_UPDATE_LINK_DATA may be the approach that may work for your needs.
You may want to review the HookImpl sample code included with the ProjectWise SDK as it sets up a pre, action and post hook which you can use as a "starting" point for your efforts.
Does AAHOOK_CODE_GENERATION_DLG provide the Document placeholder via the AACODEGENDLG_PARAM Structure or do I need to use AADMS_ECODDEF_TYPE_RESULTCODE?
I'm not sure if AACODEGENDLG_PARAM lplAttrRecordIds holds this value in the array.
Kevin, looking at the documentation for AACODEGENDLG_PARAM, it looks to me that all that is passed for the hook event are arrays of various properties for the documents and their attribute rows.
That's pretty typical of the kind of information that is passed for a hook. Just enough for you to go get any other information that you are interested in. I'm sure this approach was taken for performance reasons.
I suspect that what you need to do is first determine if the environment for the document(s) that you are interested in has document coding enabled, and if so then determine which document attribute column is the "place holder", and then you can select that document (or attribute row) to get the value.
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?