0

I created a new quick action to Add a Note on the Account object, but even though I go to the Search layout/List this action is not available there.

Is it possible to do this? I would like to select several Accounts in the listview and add the same Note to them all in one go, rather than each one individually.

0

Create vf page:

<apex:page showHeader="false" 
           sidebar="false"
           standardController="Account"
           recordSetVar="accounts"
           extensions="pocAccountController"
           action="{!retrieveSelectedAccounts}">

    <apex:pageBlock>
        <apex:pageBlockTable value="{!selectedAccounts}" var="acc"  >
            <apex:column value="{!acc.Name}" />
        </apex:pageBlockTable>
    </apex:pageBlock>

</apex:page>

recordSetVar will tell that it can be used in list button. Now apex extension class:

public class pocAccountController {

    private ApexPages.StandardSetController standardController;
    public List<Account> selectedAccounts{get;set;}

    public pocAccountController(ApexPages.StandardSetController standardController){
        this.standardController = standardController;
    }

    public PageReference retrieveSelectedAccounts()
    {       
        Map<Id,Account> selectedAccountsMap = new Map<Id,Account> ((List<Account>)standardController.getSelected());
        selectedAccounts = [SELECT Id, Name FROM Account WHERE Id=:selectedAccountsMap.keySet()];
        System.debug('selectedAccounts => '+selectedAccounts);
        return null;        
    }

}

retrieveSelectedAccounts is invoked directly on page. Now create a list button.

enter image description here

Then add it in search layout:

enter image description here

Now button is visible in list layout (any other list view except Recently viewed).

enter image description here

Clicking on it will get selected accounts:

enter image description here

List button can send selected records only to visualforce page currently. If you need to show lightning component, then you can use pageReference URL (lightning/cmp/c__myComponent) and pass the records Ids as parameters

| improve this answer | |

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.