Set data (current nid) to entity reference field with rules and VBO I'm currently stuck in the creation of a custom rule.

I would like to show a button on some content type, this button called a list of other content called "guide". I list these contents (guide) in a view and I added a field to associate a rule vbo.
In the type of content I have a guide entity reference fields might add my id of the current node content (the button add to the guide) to guide one or more listed.

How to perform the action:


get the nid of current content
define the fields at the end of the reference entity or selected guides
save the guide(s)


Note : The list of guides is showed in a lightbox when button "add to guide" in a content was clicked.

Thank you very much in advance
I will first confirm if I understood this correctly.


You have a content type where you will show a button. Let's call this content type MainType.
You have another content type called guide.
You have an entity reference field on guide which points to a particular node (nid) of content type MainType.
In nodes of MainType, there is a button which shows all guides pointing to the visible node. You already have this view.
You want to add a link which will create a new guide node with entity reference pointing the node on which the link was clicked.
From your comment: You want to use VBO to set referenced field in selected guide nodes to the current node.


I can't think of a way to do this without code, as the context of the original node is probably lost in the view of guide nodes. However, you can do it in a slightly different way:

Create a Rules component with two variables, both of Node type. First one is your guide node, set by VBO and the second will be your reference to the node.

You should then write your rules actions to set entity field value for guide node's field to the nid of second reference. You can take a look at this video which implements a very similar requirement.

I hope this helps.