possible to re-save a node with rules?

Events happening in the community are now at Drupal community events on www.drupal.org.
itserich's picture

Is it possible to re-save a node through Rules?

I am importing thousands of nodes via feeds and it appears one (computed?) field does not populate until it is resaved.

I have tried converting the node, populating a field, publishing and publishing via Rules.

None of those actions creates the same result as editing the node, and saving it again.

Comments

I think this is no longer an

itserich's picture

I think this is no longer an issue for my project.

Try action 'save node'

itangalo's picture

If this is still relevant for your project, try the save node action. It should make all computed fields update themselves.

Cheers!
//Johan Falk

Thanks Johan. I had tried

itserich's picture

Thanks Johan.

I had tried Save Node within Rules but it did not have the same effect as Saving the node in the regular way for this purpose.

To be more clear, we are importing thousands of addresses and want to geocode them. It seems a long running comment that importing addresses does not result in simultaneous geocoding.

I think the solution is to geocode before importing, and there are a lot of external geocoding options such as by spreadsheet, so looking at that.

Thanks for your always helpful comments.

VBO?

choster's picture

This issue was brought up a few years ago in http://drupal.org/node/195013 , but the consensus today seems to be that http://drupal.org/project/views_bulk_operations should do the trick.

Thanks VBO may work for

itserich's picture

Thanks VBO may work for computed fields.

I am not even sure if computed fields is the right term for what needs to happen to populate the geography field upon import.

There are various comments over the years about the node needing to be saved before the geography field (in this case OL WKT via Geocode module) is properly populated and displayed. I termed it a computed field but do not know if that is accurate.

I did manage to populate the spreadsheet with geocode prior to import, by converting zip codes to long / lat, and the long / lat properly pasted into the WKT field.

However, the lat / long data I used is not as accurate as it would be if it were calculatd upon import because it is based on a 5 digit zip code, not nine digits. Apparently 9 digit stand alone solutions are quite expensive.

So, geography upon import is still a good thing if it can be made to happen. I stopped looking for now.

automate node resave autonodetitles rules nid

Stomper's picture

I am using autonodetitles on several content types and have used the nid token in the title. Since the nid is only created after the first initial save, I need to resave each node in order for the nid to appear in the title.

I would like to automate this procedure using rules module but do not know how. I considered VBO but do not want to have to create a view for a function that needs to be done all the time, not a one time case.

Thanks

to save the node

candelas's picture

in the DO
create an
Execute custom PHP code
and in the code field, to be able to save the node, write this drupal function:
node_save($node);

Thanks!

aharown07's picture

This sounds like the answer I've been looking for. Don't know why I didn't think of it. Maybe I'll get a chance to give it a try later today.

I am trying to use the

hampshire's picture

I am trying to use the node_save($node); in Drupal 7 to re-save a node but am getting the following error. Does anyone know what might be causing this.

If the rule runs before saving content I get

Notice: Undefined property: stdClass::$is_new in node_save() (line 1063 of //modules/node/node.module).
Notice: Undefined property: stdClass::$is_new in node_save() (line 1089 of /
/modules/node/node.module).
Notice: Undefined property: stdClass::$is_new in node_save() (line 1095 of /*/modules/node/node.module).

If the rule runs after saving content I get

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '210' for key 'PRIMARY': INSERT INTO {node} (nid, vid, type, language, title, uid, status, created, changed, comment, promote, sticky, tnid, translate) 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, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13); Array ( [:db_insert_placeholder_0] => 210 [:db_insert_placeholder_1] => 210 [:db_insert_placeholder_2] => photos [:db_insert_placeholder_3] => und [:db_insert_placeholder_4] => afte [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => 1321224429 [:db_insert_placeholder_8] => 1321224429 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 1 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 0 [:db_insert_placeholder_13] => 0 ) in drupal_write_record() (line 6884 of /*/includes/common.inc).

Thanks

is_new is missing

itangalo's picture

The node you're saving need either to have a NID or have the is_new property set to TRUE.
See http://api.drupal.org/api/drupal/modules--node--node.module/function/nod... for more information.

I am sorry. Whats the "DO"?

bullz's picture

I am sorry.
Whats the "DO"?

DO

dankoB's picture

I think DO stands for Data Object. Still not clear to me where to create and insert this custom PHP code though.

That's so simple. I wish I

Stomper's picture

That's so simple. I wish I knew more PHP, everything seems to be able to be solved with code. I'm surprised there is no "update autonodetitles" option. One would think that the developers of the module would want to be able to provide such functionality with rules.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: