I'm creating a Relation entity via Rules. (I've pasted the rule below.) If you're interested in the use case: The relation connects a user to a node. I create an "endpoints" variable as a list of any entity type, add the user and node entities to that list, and then assign the "endpoints" variable to the endpoints field of the relation.
Point being: when I check the box for "Enforce uniqueness" in the "add an item to a list" action, it doesn't allow me to add both a user entity and a node entity if they both have the same ID. That is, user 1 is not allowed to be connected to node 1, because it considers those to be the same item and thus not unique—even though they're a totally different entity type.
Rule config below:
{ "rules_create_enrollment_from_product" : {
"LABEL" : "Create enrollment from product",
"PLUGIN" : "rule",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "line_item" : { "label" : "Line item", "type" : "commerce_line_item" } },
"IF" : [
{ "data_is" : { "data" : [ "line-item:type" ], "value" : "product" } },
{ "data_is" : { "data" : [ "line-item:commerce-product:type" ], "value" : "enrollment" } }
],
"DO" : [
{ "variable_add" : {
"USING" : { "type" : "list\u003Centity\u003E", "value" : [ "" ] },
"PROVIDE" : { "variable_added" : { "endpoints" : "Endpoints" } }
}
},
{ "list_add" : { "list" : [ "endpoints" ], "item" : [ "line-item:order:owner" ] } },
{ "list_add" : {
"list" : [ "endpoints" ],
"item" : [ "line-item:commerce-product:field-enrollment" ]
}
},
{ "entity_create" : {
"USING" : {
"type" : "relation",
"param_relation_type" : "enrolled_in",
"param_endpoints" : [ "endpoints" ]
},
"PROVIDE" : { "entity_created" : { "enrollment" : "Enrollment" } }
}
},
{ "data_set" : {
"data" : [ "enrollment:field-start-date" ],
"value" : [ "site:current-date" ]
}
},
{ "entity_save" : { "data" : [ "enrollment" ] } }
]
}
}