You need to sign in to do that
Don't have an account?
Brenzo
Incremental Counter Not Counting Properly
I have a custom javascript button on the Opportunity object that when clicked should icnrease the value of a numerical field by '1' but instead it's simply adding '1' to the existing value. So if the number in the field is currently '1' then clicking the button changes it to '11' and clicking again changes it to '111' and so on... it's as if it is simply appending a '1' to the end of the numerical string.
Here is my code to update the counter field 'VelocifyResync':
Here is my code to update the counter field 'VelocifyResync':
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/38.0/apex.js")} var opp = new sforce.SObject("Opportunity"); opp.Id = '{!Opportunity.Id}'; var VelocifyResync = '{!Opportunity.Velocify_Resync__c}'; // assign values to fields on opportunity object opp.Velocify_Resync__c = VelocifyResync + 1; //save the change var result = sforce.connection.update([opp]); if(result[0].getBoolean("success")) { window.location.reload();; } else { alert('Error : '+result); }Appreciate any help here!
All Answers
A var is text by default in Javascript.
Replace line 6 of your code with the following code and you will be good.
Try this :-
It should work for you.. :)
Some of records have a. blank/null value in the counter field (I've since updated this field to have a default of '0' moving forward, but that doesn't help me retroactively.)
Is there an easy way to put. some if/then conditional logic in place so that if the value in that field is blank or null it'll update it to '0' otherwise increase count by '1'. Here is what I attempted:
Thanks again in advance.