How to create your plugins

If you do not know what is a plugin in Arc, you should read first this Help article:

Creating a Plugin

The easiest way to create a plugin is to copy an existing example and then update as required. The steps to do this are as follows:

  1. Copy the directory containing the plugin. For example, Arc\plugins\bedrock-cube-clone.
  2. Edit the plugin.js file updating the name of the plugin so it is unique. A good idea is to use your name or domain as a prefix to your plugins. The name must be updated in two locations, in the definition and on the service/directive (see below).
  3. Update the rest of the plugin information and refresh the page.

The README file in the plugins directory contains a description of each of settings you can update when defining a plugin:

There are 4 arguments to pass through to the plugin function:
    name:   The name to use for the plugin, this must be unique or an error will occur.
            Use your name or domain as a prefix to make it unique
    label:  The label is what you will see in the menu 
    type:   The type of plugin, options are: page, menu/dimension, menu/cube, menu/process, menu/chore
    options: Extra (optional) options for the plugin as an object:
        icon:           A font-awesome class for the icon you want to display
        instanceName:   Restrict the plugin to a particular TM1 instance
        objectName:     Restrict the plugin to a particular TM1 object
        description:    A description of what the plugin does
        menu:           A parent menu to add the plugin to: dimensions, cubes, processes, chores, administration, tools
        version:        The version of the plugin
        author:         Your name
        url:            A URL that people can use to find out more details about the plugin

After defining a plugin you must create either a service (for menu plugins) or directive (for pages)
The service/directive name must match the plugin name used above
Menu plugins MUST implement one interface execute(instance, name)

Executing a TI Process from a Plugin

One of the easiest things to add to a plugin is executing a process or chore. You can see some examples of this in all of the menu plugins: bedrock-cube-clone, bedrock-dimension-clone, general-ledger-load and process-execute

Before you can execute a process or chore you need to include the $tm1 service in your plugin, if you have copied an existing plugin it will already be there.

The $tm1 service has following parameters to call a process and chore:

  • $tm1.processExecute(instanceName, processName, parameters)
  • $tm1.choreExecute(instanceName, processName)

If you pass 2 parameters to processExecute leaving the parameters blank Arc will retrieve the list of parameters and present the user with a dialog box for input.

If you want to execute the process directly without user input you should pass through the parameters:

$tm1.processExecute(instance, "Bedrock.Dim.Clone", [
        Name: "pSourceDim",
        Value: name
        Name: "pTargetDim",
        Value: newName
        // It has finished with success

Both processExecute and choreExecute return a promise (then function) that can be used to update the UI after the process is complete. If the process you are running is add or deleting objects your can refresh the menu on completion using $rootScope.reloadInstance(instance); See above example.