Change node author with Rules I have field in content type called field_new_author which is User reference field.

I need to make a Rule to change Node author field to match value in field_new_author.
I tryed this solution: Change node author on node save with rules

But I'm getting database error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '4141-0-all' for key 'PRIMARY': INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 4141 [:db_insert_placeholder_1] => all [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 0 ) in node_access_write_grants() (line 3440 of /home2/test/modules/node/node.module).

I also tryed different setups in Rules but could not find anything that would work.
I assume you are using D7 with Entity Reference.  You should be able to do this with stock Rules, without any PHP code:


Create a new rule
Event, select "After updating existing content"
Condition, select "Content is of type" to match whatever content type it is.  This will qualify the fields so that you can use them later
Condition, select some other limiting condition so that you don't target every single node with updated content.  You could, for example, do a data comparison to check if the content has a given taxonomy term
Action, select "Set data value".  Your target should be node(updated content):author.  Your new value should be node(updated content):field-new-author