How to use Rules to set a value for a multi-value field? I'm trying to create an Order reference on Products when ever a new order is created. I have installed the "Order Reference" module and created an Order reference field on my product type.

Next I created the following rule:


Rules Event: After saving a new commerce line item
Rules Conditions:


Data comparison ( [commerce-line-item:type], Data value: Product )
Data comparison ( [commerce-line-item..., Data value: NAME OF TYPE )

Rules Action: Set data value [commerce-line-item..., Value: [commerce-line-item:order]


The above rule works fine as long as i limit the Order Reference field to 1 value, but as soon as it is set to multiple the rule breaks.. i get the following error for the action:


  Error: The data type of the configured argument does not match the
  parameter's value requirement.


I'm new to the Rules module and a kind a lost here. Any help?

Below is the exported rule:

{
  "rules_test_test_order_ref": {
    "LABEL": "test test order ref",
    "PLUGIN": "reaction rule",
    "OWNER": "rules",
    "REQUIRES": [
      "rules",
      "entity"
    ],
    "ON": {
      "commerce_line_item_insert": []
    },
    "IF": [
      {
        "data_is": {
          "data": [
            "commerce-line-item:type"
          ],
          "value": "product"
        }
      },
      {
        "data_is": {
          "data": [
            "commerce-line-item:commerce-product:type"
          ],
          "value": "iq_test_event"
        }
      }
    ],
    "DO": [
      {
        "data_set": {
          "data": [
            "commerce-line-item:commerce-product:field-order-reference"
          ],
          "value": [
            "commerce-line-item:order"
          ]
        }
      }
    ]
  }
}
Looks like you could just use the "Add to list" Rules Action. And since your question is about a multi-value field, for sure you should NOT use a  Rules Action like "Set a data value", which is used to set assign a single value to a field (which seems to be what you've tried, a common mistake when using the Rules module for such fields).

Refer to the answer to "How to set multiple values to an unlimited Term Refence field with Rules" for "some" more details ...

PS: I'm assuming this question is about D7.