I can’t believe I forgot to add this to the “What’s New” page in the SDK documentation.  New in the Vault 2013 API, you have the ability to jump to a different location when you custom command completes.  This is a useful feature if, for example, your command creates a folder and you want the user to navigate there.

To enable this feature, you just need to set GoToLocation property on the ICommandContext object that gets passed into your custom command.  It works similar to ForceRefresh.  You set the value somewhere in your custom command, and Vault Explorer performs additional actions when your command completes.  And yes, you can use GoToLocation and ForceRefresh together.  The refresh happens first, then the location jump happens next.

To set GoToLocation, you need to set up a new LocationContext object.  That object has 2 parts to it.  One part is the SelectionTypeId, which is basically the type of object we are navigating to.  The other part is the FullName, or path, to the object.  Because we are dealing with navigation tree locations, the currency is names and paths instead of IDs.

What you put for FullName is dependent on the object type.  Here is a table that explains the values.

Entity Class LocationContext.FullName
File Full Vault path to file
Folder Full Vault path to the folder
Item The Item number
Change Order The Change Order number
Custom Entity The Custom Entity number


Comments

13 responses to “GoToLocation”

  1. Nice, do you have a code example for the GoToLocation? thx!

  2. Hi,
    GoToLocation works but I wonder about the following:
    Is it possible to call CommandItem.Execute method by code?
    So I can use the GoToLocation at any time I want (also OnLogOn event).

  3. Sorry, but you cant call GoToLocation whenever you want. It won’t work during events like LogOn or LogOff. It also won’t work inside of a custom tab.

  4. Thanks you for your post!
    I hoped to store a session state at OnlogOff and jump to the last location OnLogOn. But all this will need to work by CommandItems(Buttons).
    I see I can’t use GoToLocation for SelectionTypeId.FileVersion and SelectionTypeId.Bom because there is no fullname for it.

  5. Hi Doug,
    Is there any possibility to invoke custom command from a code in order to navigate to the different files from my extension dialog?

  6. GoToLocation only works after your command exits the Execute function.
    So if you want to navigate while keeping your dialog open, then the answer is no. But if you want to close your dialog before navigating, then the answer is yes.
    There are some sample apps that use GoToLocation and a custom dialog:
    – Advanced Advanced Find 2014
    – Find Orphaned Files

  7. Any way to access ‘GoToLocation’ from inside of DetailTabs() section?

  8. Sorry, no. GoToLocation is for commands only.

  9. I’m not able to get it to work for Custom Entities. I want to select the created CustomEntity:
    CustEntDef CED = GetCustomerEntityDefinition(CustEntName, ServiceManager);
    CustEnt CE = ServiceManager.CustomEntityService.AddCustomEntity(CED.Id, “testing”);
    if (CE != null) e.Context.GoToLocation = new LocationContext(new SelectionTypeId(CED.Name), CE.Id.ToString());

  10. Try replacing “CE.Id.ToString()” with “CE.Num”

  11. ok, now it’s working … thx

  12. is there a way to use GoToLocation for Links?

  13. I don’t know, I never tried it. If it works, it’s an unsupported feature.
    The preferred behavior is that you go to the object the link points to, and not go to the link itself.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading