0

I have a form that contains different set of fields that will be connected to different review type / content type. The values of the form will be copied to that specific review type using the rules set data value but I have a problem with setting the value of the rating.

For example this is the Overall review form:

  • Review type A: Rating 3/5
  • Review type B: Rating 2/5
  • Review type C: Rating 1/5

I need these ratings to be sent on each of the content type/review type.

On the rules I can see all the correct fields, but whenever I check the review type content only the rating is not set.

This is my sample exported rule of copying the rating from one node to another:

{ "rules_copy_rating" : {
"LABEL" : "Copy Rating",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_conditional" ],
"ON" : { "node_insert--overall_review" : { "bundle" : "overall_review" } },
"IF" : [
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_overall_review_rating" } },
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_overall_ref_review" } }
],
"DO" : [
  { "entity_fetch" : {
      "USING" : { "type" : "node", "id" : [ "node:field-overall-ref-review:nid" ] },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "CONDITIONAL" : [
      {
        "IF" : { "entity_has_field" : { "entity" : [ "entity-fetched" ], "field" : "field_form_rating" } },
        "DO" : [
          { "data_set" : {
              "data" : [ "entity-fetched:field-form-rating" ],
              "value" : [ "node:field-overall-review-rating" ]
            }
          },
          { "entity_save" : { "data" : [ "entity-fetched" ], "immediate" : "1" } }
        ]
      }
    ]
  }
]

} }

NOTE: My fivestar rating widget for the reference review type is "Stars (rated while editing)" NOT Stars (rated while viewing)

  • Do you save the entity after setting the value? – Neograph734 May 25 '16 at 12:53
  • Yes. it's Force saving immediately: true after all the "Set a data value" – Danz May 26 '16 at 3:00
  • I included my sample rule on the question. :) – Danz May 26 '16 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.