Programme Step - Find Entity

This step is used to find an entity based on the entity's key, using data from the programme data or trigger.

Property Meaning
Entity Name The entity to lookup (case sensitive)
Variable Name The result of the lookup will be added to the programme data as this variable
Include Creators If set, then events linking the visit to the entity will be included
Include Edges Out If set, then events and objects linking out from the entity will be included.
Lookup Data To lookup an entity, the data to use for the lookup must be included in the __trigger of the programme data, or from a __findEntity property of the programme data.

E.g. to lookup a "Transaction" entity, there must be a "Transaction" object in the programme or trigger. The Transaction object must also include the Key field as per the model definition for the Entity to lookup. The value of the key field will be used as the lookup data.

Looking up Multiple Entities

You can override the default lookup from the __trigger by passing an __findEntity as a list of entities to lookup. E.g. to find multiple Items by name, include a modify data stop before the Find Entity Step adding a __findEntity list to the programme data:

function(m) {
  return {"__findEntity":[
    {"Name":"Custard"}, 
    {"Name":"Fraggle"}, 
    {"Name":"Pancake!"}
  ]};
}

With only the items Custard and Pancake! existing, you will get back a list like this:

"Items": [
  {
    "Stock": 10,
    "Name": "Custard"
  },
  {},
  {
    "Stock": 122,
    "Name": "Pancake!"
  }

Testing

You can test the programme using the 'Test' Tab on the right hand side of the programmes page. To lookup a transaction entity and events/entities relating to it, the programme/trigger data must contain a Transaction object with appropriate Key (ORDERID).

Add the following programme data to the test panel along with an e-mail address, and then click 'Test Step' on the 'Find Entity' Step

{
    "__trigger": {
        "Transaction": {
            "ORDERID": "2253907"
        }
    }
}

Following the lookup, the programme data will contain: -

{
    "Transaction": {
        "ORDERID": "2253907"
    },
    "__trigger": {},
    "Result": {
        "AffiliationID": "N/A",
        "Tax": 1.6,
        "City": "Kiedrich",
        "OrderID": "2253907",
        "__createdAt": 1460396564682,
        "Delivery Address": "xxxxxxx, Germany",
        "Currency": "EUR",
        "Total": 8.39,
        "Purchased Item": [{
            "__createdAt": 1460396564682,
            "Category": "1111",
            "Price": "£9.99",
            "Quantity": 1
        }],
        "Country": "Germany",
        "Region": "AL",
        "Shipping": 0,
        "Payment Method": "PAYPAL"
    }
}

The programme testing interface is shown below

Still need help? Contact Us Contact Us