I would like to create a button that appears on an Opportunity List View, when selected, allows me to update a checkbox field [Mark_As_Paid__c] for all the opportunities selected in the view.

Attached is a screen shot of the Opportunity List View that I'm referring to. The custom field check-box that I want the button to update is called "Mark_As_Paid__c" enter image description here

  • If you need a more robust solution to do more than just that one taks check this out - Creating a custom list-view button that handles multi-record selection
    – Eric
    Sep 17 '16 at 5:34
  • @Eric Eh. I think the VF page is total overkill for something that can be typed up in five minutes. If you find an example that mimics my answer, then I'd consider this a duplicate.
    – sfdcfox
    Sep 17 '16 at 5:36
  • 1
    @sfdcfox - Did not see your answer in the review, I agree. Retracted my vote and let link for reference in case it becomes "but then I want to do x.y.z"
    – Eric
    Sep 17 '16 at 5:37
  • @eric, Thank you for you assistance. I'm new to stackexchange. Is there a way to send you a direct or private message? Thanks, David
    – davidw
    Sep 18 '16 at 19:06
  • @davidw no sfse does not have messaging
    – Eric
    Sep 18 '16 at 19:07

You can use the AJAX Toolkit to do this. Here's what that looks like:


var oppIds = {!GetRecordIds($ObjectType.Opportunity)}, opps = [];
[].forEach.call(oppIds, function(v) {
    var opp = new sforce.SObject('Opportunity');
    opp.Id = v;
    opp.Mark_as_Paid__c = true;
var results = sforce.connection.update(opps);
// process results

See the Examples of Synchronous Calls document in the AJAX Toolkit manual for more information. They also discuss how to handle error messages and so on.

Also, see GetRecordIds for how that works.

  • sfdcfox, thank you very much. I really appreciate your assistance.
    – davidw
    Sep 17 '16 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.