Invoking a Trigger from a Method

While defining your method, it is possible to define it to execute a trigger asynchronously whenever the method is invoked. This section explains how to define a method to fire a trigger. The following example provides you a step-by-step procedure to invoke a trigger via a method.

Part 1: Defining Method while adding or updating Thing Definition

  1. Start defining the Method and enter the Key. For more information on defining the method, see Defining Methods

    Note the Thing definition Key and Method Key, you will need them while defining the trigger


  2. Select the Trigger from the Handler drop-down
  3. Click Update/Add
  4. Create a Thing with the Thing definition you defined. For more information on defining the Thing definition, see Creating a Thing definition

Part 2: Defining the Trigger with method.exec event containing the same key and Thing definition

  1. Click Developer >> Triggers >> New Trigger
  2. Drag and drop the method.exec event. For more information, see method.exec event

  3. Complete the trigger. For example:
  4. Click Add
  5. Navigate to the Thing with the Thing definition you defined in the Part 1 and click on the Methods tab.
  6. When you click on the method then you will be able to fire the trigger
  7. If you want to return the output from the trigger then you need to use trigger.result action to bring back the desired values
  8. When you execute your method now, you will get the result.