# How to update a computed field in a rule's “set data a value” action

I have a custom field called field_balance in the user account form which is a computed field. It keeps the actual number of coins bought by the current user. That value is supposed to change (increase or decrease) if the user makes particular manipulations on my custom content type which is called Ads.

How do I increase the field's value? By setting up the field.

How do I decrease the value? I am using Rules module to make the field's value decrease. But it doesn't work well yet. This is what I have already tried:

• The Event: After updating existing content of type Ads
• The conditions: User has roles "ad editor"
• The Action : Set a data value. But when I select the field called "site:current-user:field-balance" and hit "Continue", The Data selector turns red and a notification appears.

Here is the illustration:

What is it about the computed field that does not continue the rule? Is there any other way to update a computed field with the Rules module?

• Does your computed field allow unlimited values? or only 1 value? – No Sssweat Sep 11 '17 at 9:26
• There is no such think as the number of values on this field type. And my computed field is ment to keep only one value at a time. The calculation (in the field's settings) is always : "$field_b = field_get_items($entity_type, $entity, "field_balance");$entity_field[0]["value"] = $field_a[0]["value"] +$field_b[0]["value"];". So everytime I add something to the field, the value increases. But when I want to reduce that value (with Rules), that's when things get difficult. – mosgeorges Sep 15 '17 at 10:50
• Do you really need a computed field? Can't you create an integer field instead and change its value with a Rule every time the entity changes? – Jeroen Sep 15 '17 at 16:50
• I did that. But an integer field will be visible by default when a computed field is just like a variable (so only visible when you need to display it's value). – mosgeorges Sep 15 '17 at 16:53
• I did try that and try to hide it with the help of conditional_fields (the module). But if hidden in the form, it will also be hidden in the display page. – mosgeorges Sep 15 '17 at 16:54