function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Btuitasi1Btuitasi1 

Formula field to add 1 to number field

I have two formula fields (UpVotes and DownVotes). When a text field (Score_Button__c) is changed to "Up" then add 1 to UpVotes. If Score_Button__c is changed to "Down" then add 1 to DownVotes. Here is what I have figured out so far:
 
IF(Score_Button__c = "Up",+ 1, null) 
After this gets assigned, I'll have a trigger reset the Score_Button__c value to a blank. My problem is that once the field gets reset, the value gets reset as well. I want to keep the +1 value that occurred before the trigger reset.

Any ideas on how to fix my formula?

Thanks!
 
Best Answer chosen by Btuitasi1
BalajiRanganathanBalajiRanganathan
you can achive your requirement with workflow rules and field updates. have two workflow rule, one to update UpVotes and one to update downvotes. both the workflow rules can have one more action to reset the Score_Button__c  field to null

All Answers

YuchenYuchen
I think you can move the logic of adding 1 to UpVotes/DownVotes to your Trigger. And you will need to change the formula fields to plain text field instead. Because if it is formula, it will always check the current value of "Score_Button__c".
BalajiRanganathanBalajiRanganathan
you can achive your requirement with workflow rules and field updates. have two workflow rule, one to update UpVotes and one to update downvotes. both the workflow rules can have one more action to reset the Score_Button__c  field to null
This was selected as the best answer
Btuitasi1Btuitasi1
I ended up adding a workflow to each field. When Score_Button__c is "Up", the workflow adds 1 to the UpVotes field (Formula: UpVotes+1) and then changes Score_Button__c to null. I implemented the same thing for DownVotes. One thing I had to do was, make 0 the default value for UpVotes and DownVotes. Also, I added a ScoreTotal field combining the two fields. 

Thanks for the help!!