Watch for specific event

Watch for specific event

gert-leonvanlier
Collaborator Collaborator
857 Views
5 Replies
Message 1 of 6

Watch for specific event

gert-leonvanlier
Collaborator
Collaborator

Probably it is pretty simple what I am looking for, but I can not find the answer.

 

I want to create a (custom) event in my add in using C#. With the even watcher I found the command I want to watch for is UserInputEvents.OnActivateCommand with command name "VaultCheckinTop". How do I create an events that watches this event?

0 Likes
Accepted solutions (1)
858 Views
5 Replies
Replies (5)
Message 2 of 6

Ralf_Krieg
Advisor
Advisor

Hello

 

Just listen to the OnActivateCommand event and every time it fires, check if CommandName is "VaultCheckinTop". There's no specific event "VaultCheckinTop" you can listen to.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 6

gert-leonvanlier
Collaborator
Collaborator

I created this method:

private void ui_OnActivateCommand(String CommandName, NameValueMap Context)
{
	switch (CommandName)
	{
		case "VaultCheckin":
			MessageBox.Show("VaultCheckin");
			break;
		case "VaultCheckinTop":
			MessageBox.Show("VaultCheckinTop");
			break;
	}
}

 

I am now looking on how to trigger this method. ApplicationEvents are triggered by for example this:

Globals.invApp.ApplicationEvents.OnDocumentChange += onChange;

 

I can't find anything for UserInputEvents or OnActivateCommand.

 

0 Likes
Message 4 of 6

gert-leonvanlier
Collaborator
Collaborator
Accepted solution

Found it!

 

The following is placed in the Activate method of the add in:

Globals.invApp.CommandManager.UserInputEvents.OnActivateCommand += UserInputEvents_OnActivateCommand;

 

And this is in my case the method for the OnActivateCommand:

private void UserInputEvents_OnActivateCommand(string CommandName, NameValueMap Context)
{
	switch (CommandName)
	{
		case "VaultCheckin":
			MessageBox.Show("VaultCheckin");
			break;
		case "VaultCheckinTop":
			MessageBox.Show("VaultCheckinTop");
			break;
	}
}

 

0 Likes
Message 5 of 6

gert-leonvanlier
Collaborator
Collaborator

I just found out that this events works as some kind of before: when you click the button, the event is fired. At that point I can run some code and after that the check in window is shown. Although you can't choose for before or after, is there a way to have my code to run after the check in window is shown?

0 Likes
Message 6 of 6

Ralf_Krieg
Advisor
Advisor

Hello

 

Thats right and that's why it is called "OnActivate".

You can check if the OnTerminateCommand (this should fire if the command is finished or aborted) is useable. Maybe it would be a better way to use the (Webservice)API of Vault server direct.

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes