Creating records by using a LoopBackRequest node

Use the LoopBackRequest node to create a new record in a backend data source by using a LoopBack® connector.

About this task

You can use a LoopBackRequest node in a message flow to create a new data record through a LoopBack connector in a backend data source such as MongoDB, Cloudant®, or PostgreSQL.

You create a new record by specifying Create in the Operation property of the LoopBackRequest node, and specifying the resource type (such as Account) in the LoopBack object property. The object can be overridden by the LocalEnvironment.Destination.Loopback.Request.object local environment variable. For more information about using environment variables, see Using local environment variables with LoopBackRequest nodes.

The record that you are creating must exist in the input message tree as a JSON object. When the record is created, the input message tree is copied to the location specified by the Output data location property. The output data might also be augmented with additional data that was created in the backend data source.

Procedure

  1. Create a flow containing a LoopBackRequest node, and set the node properties:
    1. On the Basic tab, set the following properties:
      • In the Data source property, specify the name of the data source stanza for your chosen connector in the LoopBack datasources.json file.
      • In the Operation property, specify Create.
      • In the LoopBack object property, specify the type of object (for example, Account) for which you are creating a new record.
      • In the Security identity property, specify the security identity that you will use when connecting to the LoopBack connector. For information about configuring the security identity on the integration node, see Specifying security credentials for connecting to a secured data source.
      • In the Timeout (milliseconds) property, specify the time (in milliseconds) that the node waits for the LoopBack connector to process the operation.

      These properties can be overridden dynamically in the flow, as described in Using local environment variables with LoopBackRequest nodes.

    2. On the Request tab, set the Data location property to specify the location in the incoming message tree that contains the JSON object data to be created in the external application; this data forms the request that is sent from the LoopBackRequest node to the connected system.
    3. On the Result tab, set the Output data location property to specify the location in the output message tree that will contain the data of the record that is created.
      Input and output messages are in the JSON domain. For more information, see Combining a result message with an input message when fetching data from external systems.
    For more information about the properties of the LoopBackRequest node, see LoopBackRequest node.
  2. Send the required message through the flow to the backend data source.
    You will receive a confirmation message, which might be augmented with additional data from the backend data source. The message will be in the JSON domain and can be created and processed by any suitable transformation node. To use the Mapping node, you must provide a message model of the data, as described in Creating or transforming a JSON message by using a JSON schema.
  3. Check the backend data source to verify that the new record has been created correctly.
    You can also check the activity log for additional information about events related to the LoopBackRequest node. If the Loopback operation was not successful, the node reports by raising an exception with a BIP message that might include an error returned from the installed LoopBack connector. If the failure terminal is connected, the node will propagate the exception list to it, otherwise the flow will roll back.