You need to sign in to do that
Don't have an account?
Creating a OnClick Javascript List View button
I have a Custom Button that is on a Custom Object called Reviewer that will update a checkbox called "On Project" back on a Contact record. I need a little help putting this on the List View of the Custom Object called Reviewer. Is this possible?
Thank you very much for your help! My code is below.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var selectedReviewers =
{!GETRECORDIDS("Contact")};
if(selectedReviewers.length > 0){
var reviewersToUpdate = [];
for(var i=0; i<selectedReviewers.length; i++){
var updatedReviewer =
new sforce.SObject("Contact");
updatedReviewer.Id = selectedReviewers[i];
updatedReviewer.On_Project__c = '1';
reveiwersToUpdate.push(updatedReviewer);
}
var result =
sforce.connection.update(reviewersToUpdate);
location.reload();
}
else{
alert(
"Please select at-least one record."
);
}
Thank you very much for your help! My code is below.
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var selectedReviewers =
{!GETRECORDIDS("Contact")};
if(selectedReviewers.length > 0){
var reviewersToUpdate = [];
for(var i=0; i<selectedReviewers.length; i++){
var updatedReviewer =
new sforce.SObject("Contact");
updatedReviewer.Id = selectedReviewers[i];
updatedReviewer.On_Project__c = '1';
reveiwersToUpdate.push(updatedReviewer);
}
var result =
sforce.connection.update(reviewersToUpdate);
location.reload();
}
else{
alert(
"Please select at-least one record."
);
}
Yes, it is possible. Follow below steps to add custom list button on List View.
1. Go to Setup
2. Go to Create --> Object --> Select your custom Object ("Reviewer").
3. Scroll down to the "Search Layouts" sections.
4. Edit --> "Search Results"
5. Add your custom button.
Let me know if you have any question on this. Please mark this "Solved" if it helps.
Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com
http://mrjavascript.blogspot.in/
I think you have to give your sObject name ("Reviewer") instead of Contact in below line.
Let me know if you have any question on this. Please mark this "Solved" if it helps.
Previous Code: New Code:
var selectedReviewers = {!GETRECORDIDS("Contact")};
Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com
http://mrjavascript.blogspot.in/
That did not work. I still received the error "ReviewerToUpdate" not defined.