3

I want to use rules in order to populate Organic Groups field X value with the value of field Y. Keeping in mind these fields are Organic Group fields.

Field X is a 'long text & summary' field, while field Y is a normal 'text field'.

I'm trying to use Rules Actions to achieve this but no luck so far.

Any suggestions?

1

Here is a rule (in Rules export format) that should be close to what your question is about:

{ "rules_og_populate_fields" : {
    "LABEL" : "OG populate fields",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "og" ],
    "ON" : { "og_user_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_x" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_y" } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "node:field-y" ],
          "value" : "[node:title-x]"
        }
      }
    ]
  }
}

You didn't specify which Rules Event you want to use. In my sample, I used "User has become a group member" (adapt the event to fit your own needs).

Notice the "entity has field" conditions, for both fields. Those conditions will make the fields available in the Rules Action ... (so that you can reference field X and set the value of field Y).

If you have the Rules UI enabled, and if the machine names of your fields are indeed "field_x" (for field X) and "field_y" (for field Y), you should be able to just import this rule in your own site. If you're using other machine names, just adapt the machine names prior to importing this rule (and apply similar changes in the fields mentioned in the Rules Action).

Your Answer

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

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