How can I know if I am in the Item Record Window or not?

How can I know if I am in the Item Record Window or not?

smilinger
Advisor Advisor
693 Views
3 Replies
Message 1 of 4

How can I know if I am in the Item Record Window or not?

smilinger
Advisor
Advisor

If I add a detail tab for items, it will show in both Item master and the Item Record window (right click and select Edit), is there any attribute in the context or sth. so that I can realize whether I am in the Item Record window (where the item is already editable) or not (where I must call EditItems to get it editable)?

0 Likes
Accepted solutions (2)
694 Views
3 Replies
Replies (3)
Message 2 of 4

Redmond.D
Autodesk
Autodesk
Accepted solution

Unfortunately there is no navigation context for tab views.  It's on our list to fix.

 

If you are in Vault 2012, I have a workaround for you.  In your OnStartup function, hook to the application.CommandBegin and application.CommandEnd events.  When the Item edit window opens, you will get an event for the "Item.Edit" command.  When the window closes, you get the end event for the "Item.Edit" command.  So the item is in an editable state between these two events.

 

Here is what the C# code would look like....

----------------------------------------------------------------------------

private bool m_isItemEditable = false;
public void OnStartup(IApplication application)
{
    application.CommandBegin += new EventHandler<CommandBeginEventArgs>(application_CommandBegin);
    application.CommandEnd += new EventHandler<CommandEndEventArgs>(application_CommandEnd);
    return;
}

void application_CommandBegin(object sender, CommandBeginEventArgs e)
{
    if (e.CommandId == "Item.Edit")
        m_isItemEditable = true;
}

void application_CommandEnd(object sender, CommandEndEventArgs e)
{
    if (e.CommandId == "Item.Edit")
        m_isItemEditable = false;
}

 

 

 



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes
Message 3 of 4

jan.liska
Autodesk
Autodesk
Accepted solution

Alternate option is to check type name of parent form:

 

if (ParentForm != null)

{

    Type formType = ParentForm.GetType();

 

    if (formType.Name.Equals("EditCreateForm", StringComparison.InvariantCulture))

    {

        ...

    }

}


Jan Liska
Developer Advocate, Autodesk Tandem

0 Likes
Message 4 of 4

smilinger
Advisor
Advisor
0 Likes