Search Results for

    Show / Hide Table of Contents

    Plugin API

    Casewhere provides a set of APIs to interact with plugins from different places in the solution. A typical place to invoke plugin methods is from inside a workflow. You can also invoke plugins from the worker site.

    Execute plugin from workflow

    From a workflow scripted activity, you can invoke plugin methods using the interface IPluginApi.

    PluginMethodResult Invoke(string pluginName, string methodName, IDictionary<string, object> parameters);
    

    Here is an example how it can be done:

    var pluginApi = ctx.Use<IPluginApi>();
    var testApi = ctx.Use<ITestApi>();
    
    var parameters = new Dictionary<string, object>();
    var result = pluginApi.Invoke("HelloWorld", "HelloWorldMethod", parameters);
    testApi.Set("result", result.Get<string>("Greeting"));
    

    The PluginMethodResult class provides properties and methods to help retrieve data from the plugin:

    • Data: A key-value data collection returned from the plugin.
    • T Get<T>(string name): Get data for a given key. Use this method when you know exactly the type of the data.
    • JObject GetObject(string name): Return data as a JSON object. Return null if the item is not in JSON format.
    • JArray GetArray(string name): Return data as a JSON array. Return null if the item is not in JSON format.

    Execute plugin from worker site

    Note: You can only invoke public plugins from worker site.

    From a custom widget, you can invoke plugin methods using the PluginService.

    var parameters = { Name: "John Doe" };
    
    PluginService.invoke("pluginName", "pluginMethodName", parameters)
    	.then(function (pluginResult) {
        	console.log(pluginResult);
        }, function (error) {
        	console.log(error);
        });
    
    In This Article
    Back to top Generated by DocFX