0

I have a content type, Company, which is referenced to a User with an entity reference. The token for that entity reference for the current user is [current-user:field_user_company].

No matter how I configure the field I'm using the token in, when using this token, it always translates in a the label with a link <a href="/node/17" hreflang="en">TEST COMPANY</a>.

Is there any way I could make this token translate into just the Node ID (17 in this case)? I would need just the ID to pass the reference on to other entities in a workflow (using Rules or Business Rules).

5
  • Not sure what version of Drupal you're using (not sure it even matters actually), but try [current-user:field_user_company:entity:nid] – Clive Oct 24 '18 at 19:20
  • Thanks. But, no, that didn't work (for Drupal 8). The token doesn't translate at all (empty output). – Dendreten Oct 24 '18 at 19:36
  • Maybe [current-user:field_user_company:0:entity:nid] or [current-user:field_user_company:0:entity:id]`? – Clive Oct 24 '18 at 19:39
  • 1
    Or possibly [current-user:field_user_company:target_id] or [current-user:field_user_company:0:target_id] – Clive Oct 24 '18 at 19:44
  • Yes! [current-user:field_user_companies_represented:target_id] did the trick. Thanks a lot!!! – Dendreten Oct 24 '18 at 19:52
1

Adding the solution given by Clive in the comments to my question as an answer :

[current-user:field_user_company:target_id]

= the token translating into the node ID of a referenced content type.

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.