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
mromanimromani 

Update a field using a custom button

I need help. I'm trying to change the value of a field by using a custom button. I would like to be able to do it using Javascript.

 

Using this code works: alert   (     {!Box__c.Box_Count__c } +1) ; which displays the current count of my variable.

 

But when i try something like this, it doesnt work... {!Box__c.Box_Count__c } = ( {!Box__c.Box_Count__c } +1);

 

I'm trying to add 1 to whatever the value of my count is.

 

Any help would be appreciated!

 

My email in case is mromani@robotshop.com

 

Thanks

Message Edited by Bulent on 11-25-2009 02:17 PM
Best Answer chosen by Admin (Salesforce Developers) 
shillyershillyer

Two ways are described here, using Apex or JavaScript.

 

Hope that helps,

Sati

All Answers

shillyershillyer

Two ways are described here, using Apex or JavaScript.

 

Hope that helps,

Sati

This was selected as the best answer
marketforcemarketforce

Could you let me know how you solved this? I have a similar issue. My Javascript works but not as expected. Instead of adding the value of one to the number (ie going from 2 to 3) it is appending the one to the end of the number (ie going from 2 to 21).

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var l = new sforce.SObject("Lead");
l.id = "{!Lead.Id}";
l.Number_of_calls__c = ("{!Lead.Number_of_Calls__c}"+1)
result = sforce.connection.update([l]);
window.location.reload();

 

Thanks in advance for your help.

marketforcemarketforce

Wouldn't you know I"d figure it out after I post?

 

Turns out I had quotes around my original field value that was causing this.