2

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:

    1. Data comparison ( [commerce-line-item:type], Data value: Product )
    2. 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"
          ]
        }
      }
    ]
  }
}
0

2 Answers 2

1

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.

0

If anyone should be looking for the same functionality i found a solution, creating my own action, in this post :)

Update values of multiple value field programmatically? (Rules action)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.