Project GUID is returning null

141
1
01-12-2021 06:54 AM
DanielWatkins
New Contributor

Hey, I am trying to find a way to identify which project is loaded. Using the name or URI is proving problematic because the user can change those at anytime. I see that the Project object does have a method for retrieving a GUID, however whenever I call Project.Current.Guid it always returns null.

 

Is there something special I need to be doing to ensure my Projects have a valid GUID?

Tags (2)
1 Reply
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry about the delayed reply, I tried to check with the developers before responding.  You are correct as to Project.Current.Guid doesn't return the documented: ''unique identifier for the item". I attached a project that provides a workaround for the desired unique project file identifier. In order to implement this I used the API's project's custom settings capability for that.

In essence the attached add-in adds a custom setting to each project that is opened with the add-in running.  However, there are a few caveats:

The add-in has to be autoloaded in order to catch the project open events.  The default JIT loading will not provide access to the first project open event.  To do this you have to change the autoLoad property to 'true' as shown here:

<insertModule id="TestProject_Module" className="Module1" autoLoad="true" caption="Module1">

The unique identifier created for each project will only be 'permanent' once the project is saved.  This can be mitigated by saving the project programmatically in your add-in.

0 Kudos