How to add to operation search
Overview and explanations
To quickly find an operation within the Site Manager, you can use the search functionality. In the ribbon of the Site Manager under Home you should see this button:
To get the search window you can either press this button or use the shortcut Ctrl + F. The search window you get looks like this:
From the top-right corner you can select a number of search criterias. You can for example search only for customers, stores or items. If you select Customer as your search criteria you will be searching for all of the customers available in the system. But there is one special search case, and that is to search for Operations.
Operations are simply anything that you can open in the Site Manager. Below I entered the search condition Customers. The only thing that was returned was the operation View all customers. Double-clicking on this operation opens the view, showing a list of all customers.
This step by step helps you add your plugin's views or dialogs to the Site Manager operation search.
Adding an Operation to the Search
In the plugin you are working with, locate the class that implements the IPlugin interface. You should have a single class that does this. In the Site Manager this class is usually called PluginEntry. In this class you tell your plugin everything that it is supposed to do, including adding your views or dialogs to the operation search.
The function in this class that we are interested in is the GetOperations(..) function. We use this function to add to the operation search. The following code adds a view to the operation search
public void GetOperations(IOperationList operations)
{
operations.AddOperation("Search string",
PluginOperations.FunctionsThatOpensAView,
Permission.PermissionToOpenView);
}
We are calling the AddOperation function with three parameters.
The first parameter is the string we set as Search string. This is the string that the user has to enter to discover your operation. Note that this is not case sensitive and also note that the Site Manager also returns partial matches so if the user enters any of the following search terms Search, search, and string they will find your operation.
The second parameter is the operation that is supposed to be run when the user selects the search result. This should be a function that opens either a view or a dialog.
There is a third optional parameter here, a permission string that makes sure that only users with the given permission are able to access the operation.
Example
This example comes from the Customer plugin. In this example we are adding a search operation that allows us to open the customers view.
In the PluginEntry class from the Customer plugin we have the following implementation of the GetOperations methods:
public void GetOperations(IOperationList operations)
{
operations.AddOperation(Properties.Resources.ViewAllCustomers,
PluginOperations.ShowCustomersListView,
Permission.CustomerView);
}
Here we added the search text ViewAllCustomers and a function that shows a list of customers. This operation is only available to users who have the CustomerView permission.
The end result is the following, when searching:
Have you finalized the tasks to do in Lesson 3 - Plugins?