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
edel32edel32 

Close custom button for projects tab

hey
I need to create a custom button for projects so that when pressed it will automatically close the project. Its similar to the one thats used to close a case
Any help appreciated
Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf
If all you have to do is flip a status field and then reload the page, then:

1.  Make a custom button and set it to a Detail Page Button.
2.  Set it to Execute Javascript, Onclick Javascript.
3.  Put code kind of like this in there (this example is for case, obviously you have to change it for your object, but it gets the point across):

Code:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Status = 'Closed';
sforce.connection.update([caseObj]);

location.reload(true);

 

All Answers

werewolfwerewolf
If all you have to do is flip a status field and then reload the page, then:

1.  Make a custom button and set it to a Detail Page Button.
2.  Set it to Execute Javascript, Onclick Javascript.
3.  Put code kind of like this in there (this example is for case, obviously you have to change it for your object, but it gets the point across):

Code:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Status = 'Closed';
sforce.connection.update([caseObj]);

location.reload(true);

 

This was selected as the best answer
lee_carter73lee_carter73

I am looking for the same solution and tried the java listed above. 

 

I got a syntax error saying that the case.id is required.  In my case it is a different field but that is where i am getting the error.  The field i am using is an auto generated number as well so i don't see a reason why i would be getting this error.  Any suggestions?

werewolfwerewolf

Where are you putting this button exactly?

 

Follow the instructions here:

 

http://blogs.salesforce.com/support/2008/07/the-quick-case.html