This is a follow-up question of: How to delay the execution of a rule for 5 minutes?
When not delaying the action, the node:url
token does not return the alias URL, but the URL with the token ID: ...node/id
. I assumed this is because this URL is simply not available yet. I have to use the clean URL, because otherwise a scraper would get a HTTP status code 302 and is unable to scrape the page correctly.
I'm using the Pathauto module to create the URL's automatically.
However, when using the sheduler, I'm still not getting the clean URL. These are my current settings:
The marked token in the screenshot should return the clean URL, but it returns the unclean /node/id
one. I've already tried to change the token to [entity-fetched:url:path]
, but this seems to return an invalid URL (or no URL at all, is it possible to debug this?).
Why can't I get the clean URL using tokens in rules?
The weird thing is... if I edit a node instead of creating a new one, node:url
does return the clean URL, but not when using the sheduler.
EDIT:
{ "rules_publish_to_fb" : {
"LABEL" : "Publish to fb",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler", "fb_autopost_entity" ],
"ON" : { "node_insert" : [], "node_update" : [] },
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : {
"event" : "event",
"inspiration_theme" : "inspiration_theme",
"news_item" : "news_item"
}
}
}
},
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_facebook_message" } },
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_facebook_published" } },
{ "NOT data_is_empty" : { "data" : [ "node:field-facebook-message" ] } },
{ "data_is" : { "data" : [ "node:status" ], "value" : "1" } }
],
"DO" : [
{ "schedule" : {
"component" : "rules_facebook",
"date" : "+2 minutes",
"param_node" : [ "node" ]
}
}
}
And
{ "rules_facebook" : {
"LABEL" : "facebook",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "fb_autopost_entity" ],
"USES VARIABLES" : { "node" : { "label" : "node", "type" : "node" } },
"ACTION SET" : [
{ "entity_fetch" : {
"USING" : { "type" : "node", "id" : [ "node:nid" ] },
"PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
}
},
{ "entity_create" : {
"USING" : {
"type" : "facebook_publication",
"param_type" : "link",
"param_user" : [ "site:current-user" ]
},
"PROVIDE" : { "entity_created" : { "facebook_link" : "Facebook link" } }
}
},
{ "data_set" : {
"data" : [ "facebook-link:field-facebook-message" ],
"value" : "[node:field-facebook-message]"
}
},
{ "data_set" : {
"data" : [ "facebook-link:field-facebook-link" ],
"value" : "[entity_fetched:url]"
}
},
{ "publish_to_facebook" : {
"USING" : { "publication" : [ "facebook-link" ], "pages" : "1247812435236072" },
"PROVIDE" : { "facebook_publication_id" : { "facebook_publication_id" : "Facebook publication returned ID" } }
}
},
{ "drupal_message" : { "message" : "[entity_fetched:url]" } }
]
}
}
node:url
? or withsite:current-page:url