Updating records by using a LoopBackRequest node

Use a LoopBackRequest node in a message flow to update data records through a LoopBack® connector such as MongoDB, Cloudant®, or PostgreSQL.

Before you begin

Complete the tasks in the following topics:

About this task

You can update records by specifying Update in the Operation property of the LoopBackRequest node, and specifying the object type in the LoopBack object property. The object type can be overridden by the LocalEnvironment.Destination.Loopback.Request.object environment variable.

The fields of the data record to be updated must appear in the input message tree as a JSON object. Fields that do not require updating do not have to appear in the tree.

If an ID is specified in the LocalEnvironment.Destination.Loopback.Request.Id environment variable, the record with that ID value is updated. If no record is found with a matching ID, an error is returned.

If an ID is not specified, but an external ID name and value are specified in the LocalEnvironment.Destination.Loopback.Request.externalIdName and LocalEnvironment.Destination.Loopback.Request.externalId environment variables, the record with that external ID is updated. In some cases, multiple records might match the same external ID. If no ID or external ID is specified, you can use a filter.where clause to specify the records to be updated. For more information about filtering, see Filtering the records retrieved through a LoopBack connector.

When records are updated, data is returned from the installed LoopBack connector, such as a count of the updated records.

You can use JSON schema as input and output for message maps in a Mapping node, see Using models with LoopBack connectors.

Procedure

Follow these steps to update a data record of a specified type (for example, an Account object):

  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 Update.
      • In the LoopBack object property, select the type of object that you want to update (for example, Account).
      • 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 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 objects data that will be used to update the data record.
    For more information, see LoopBackRequest node.
  2. Ensure that the ID of the record that you want to update is set in the LocalEnvironment.Destination.Loopback.Request.id local environment variable.
    Alternatively, you can update records by specifying the appropriate values in the LocalEnvironment.Destination.Loopback.Request.externalId and LocalEnvironment.Destination.Loopback.Request.externalIdName local environment variables.
  3. Send the required message through the message flow to the LoopBack application.
    You will receive a response from the application to confirm that the records have been updated.
  4. Check the backend data source to verify that the records have been updated 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.