How to use Rules to change the value of entity reference’s field? I have two content types (Inventory and Sales). In Sales, I referenced Inventory using the Entity reference module. 

In Inventory, I have a stock_available (integer) field. In Sales, I also have the same field, so that I can automatically populate its value from Inventory using the Entity reference autofill module.

When I add a new Sales node, I want to adjust the value of stock_available  in the referenced Inventory, so that gradually it becomes zero in the referenced Inventory node.

I know how to set value/calculated value from other filed within same content type, by using the Rules module. 

I have no idea how I can do same things to targeted entity reference node. I think it's possible by just rule configuration. Please let me know if something needs to change to get same output that I expected.
Step 1: Create a Rules Component

Create a Rules Component (of type "action set") like so:


Parameters are "node" and "stock decrease".
Rules Action = "set value/calculated value from other filed within same content type" (*).


Here is a prototype of such Rules Component:

{ "rules_decrease_stock" : {
    "LABEL" : "Decrease Stock",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node_to_update" : { "label" : "Node to be updated", "type" : "node" },
      "stock_decrease" : { "label" : "Stock decrease", "type" : "integer" }
    },
    "ACTION SET" : [
      { "drupal_message" : { "message" : "Something just got sold, so please decrease the stock for node with id [node-to-update:nid] with an amount of \r\n[stock-decrease:value] units. To actually do so, replace this (informational) Rules Action with setting the appropriate value for the appropriate field ..." } }
    ]
  }
}


The actual action only displays a Drupal message (to show the values of the variables passed to it). Replace that action with the actual update of your inventory node (*).

Step 2: Create a Rule

Create a rule with Rules Event something like "after updating a node of content type "Sales". Maybe also some Rules Condition like "stock_available" is updated (checked if the unsaved value differs from the saved value). And add these Rules Actions:


Update the stock_available in your Sales content type (*).
Perform the Rules Component (from step 1), whereas you pass these 2 parameters:


the node, which you can pass via the value (token) of the entity reference.
the stock decrease amount (which is identical).



(*): you indicated in your question you know how to do that ...