Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
{
    "associations": [
        {
            "assoc_type": "Event",
            "entity1": "focalcrm",
            "entity1_index": "focalcrm/twitterhandle",
            "entity2": "crm",
            "entity2_index": "crm/hashtag",
            "verb": "tweets_about",
            "verb_category": "tweets_about"
        },

Best Practices for Using iterateOver for Associations

Association fields generated from the entity loop are placed in "_iterator". For example, for "iterateOver": "entity1/entity2/geo_index", an _iterator object with the following fields is available in the Javascript: "_iterator.entity1_index", "_iterator.entity2_index", "_iterator.geo_index".

These fields can be usefully used together with "creationCriteriaScript" scriptlets to filter out unwanted associations, eg when looping over entity1 and entity2 with the same entity type, the following script would ensure the association didn't involve the same entity:

"creationCriteriaScript": "$SCRIPT( return _iterator.entity1_index != _iterator.entity2_index; )", "iterateOver": "entity1/entity2", "entity1": "EmailAddress", "entity2": "EmailAddress", //etc

The creationCriteriaScript runs before the association is generated (so can be safely used to remove items that would return errors).

 

Panel

Footnotes:

Legacy documentation:

Legacy documentation:

 

...