I am trying to update nodes field values with a rule action
i want to modify the author and a link field and also some norma text fields.

It works great for normal text field but nothing for author field (which is a core field like a node reference i presume) and don't work also for link field type.

Until this is solved somebody can tell me how ti update thoses fields using a php snippet in a rule action ? instead of using Set a data value action.

Comments

khanz’s picture

Version: 7.x-2.2 » 7.x-2.6
Issue summary: View changes

Although Set a data value action works for normal text fields, wasnt able to set it up for node author field.

iacono’s picture

Same issue here. Below is the configuration for the rule.

Event:
After updating existing content

Conditions: Content is of type:
Content:[node], Content types: My content type

Actions: Set a data value:
Parameter: Data: [node:author]
Value: [node:field-assigned-manager] <--- This field is an entity reference field that references the USER bundle

I've tried different combinations of node:author and node:source:author but nothing seems to work. No errors are thrown when the field-assigned-manager is updated. That value changes, but the node author does not reflect it.

tr’s picture

Status: Active » Closed (cannot reproduce)

I tried to reproduce this but I can't. Here's the export of my Rule. This rule changes the node author to the current user and shows a message informing you of that.

If you are still having issues with setting the node author, the EXPORT YOUR RULE and post it here so we can see exactly how you have configured your Rule and what you're trying to do. The only way we would be able to confirm your issue is if we can reproduce it, and for that to happen we need specifics, we can't just guess at what you've done.

{ "rules_set_node_author" : {
    "LABEL" : "Set node author",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update" : [] },
    "DO" : [
      { "data_set" : { "data" : [ "node:author" ], "value" : [ "site:current-user" ] } },
      { "drupal_message" : { "message" : "Author set to \u0022[node:author]\u0022" } }
    ]
  }
}
giorgio79’s picture

Status: Closed (cannot reproduce) » Active

I can repro this issue. Here are repro steps:

1. Switch to "direct input" for the node:author
2. I tried setting value "0" and that did not work.
It is unclear what "User identifier" is meant by. Username or user id?

Switching back to data selector, and setting to site:current logged in user works fine.

tr’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

EXPORT YOUR RULE and post it here so we can see exactly how you have configured your Rule

And are you really using Rules 7.x-2.6 like the original poster?

giorgio79’s picture

Version: 7.x-2.6 » 7.x-2.12

Good point! Fixing.

Wonder when 7x support will be dropped as 9x is coming out though. Not sure how much effort should be expended here. :)

tr’s picture

The official D7 EOL is planned for November 2021.

allsite’s picture

The only way I've been able to automate setting a value for Author uses Feeds. You can serve up the node IDs and desired value for Author. Import the Feed using "update existing content" using node ID as the unique identifier. In mapping set the Target to user_name. When the feed imports it will change the node Author to whatever you have targeted at user_name.

tr’s picture

@allsite: I presented a working Rule more than a year ago in #3. Did you try that? What happened when you tried it? Do you have a different configuration? What is that (provide a simplified export we can use to reproduce the problem...)?

This issue is "Postponed" because no one has provided steps for reproducing the error. Without that, and with a working example that contradicts the initial bug report, I'm operating on the assumption that this is user error, not a problem with Rules.

tr’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)