0

I am working on invoking custom visualforce page with standard controller (StandardSet with checkbox functionality to pass selected record) functionality on list view by list view button with type visualforce page. It is working fine in standard org. But in communities button unable to invoke custom visualforce page because of salesforce constraints, that List view button with type visualforce page is not supporting with communities. Already tried below following approaches:

  1. Quick Action We are not able to include a visualforce page with a standard controller in quick actions.
  2. Global Action also has the same limitation as a quick action.

How should we invoke custom visualforce page from the list view in communities by the button?

1

Documentation: Visualforce custom list buttons are not supported in communities..

Reference: https://help.salesforce.com/articleView?id=community_builder_use_visualforce.htm&type=0

Not just that:

  1. Even if you give url of lightning component (using isUrlAddressable interface), it will not load.
  2. Url of vf page also does not work.
  3. Javascript button will not appear.

As an alternative, we created a different lightning component with conditional buttons and using that component in communities.

0

We can create a new list button dynamically in the lightning community using below process.

  1. Create a lightning component
  2. create a VF page and add it in the component using iframe.
  3. on the vf page use the below script to add the button to the list view.
  4. Add this lightning component at the top of the list view in the community. so that it will add a new button ("List Button") in the community list view.
<script>
    var selectedRecords = [];
    function btnClicked() {
        var elements = parent.document.getElementsByClassName("selected");
        for (var i=0; i<elements.length; i++) {
            var links = elements[i].getElementsByClassName ('outputLookupLink');
            for (var j = 0; j < links.length; j++) {
                var link = links[j];
                var recordId = link.getAttribute('data-recordid');
                selectedRecords.push(recordId);
            }
        }
        console.log (selectedRecords); // This is the array of your selected records
    }
    function addButton() {
        var li = document.createElement("li");
        var button = document.createElement("button");
        button.innerHTML = "List Button";
        button.className += " slds-button ";
        button.className += " slds-button--neutral";

        button.setAttribute("onclick", btnClicked);
        button.onclick= btnClicked;
        li.appendChild(button);

        parent.document.getElementsByClassName ('slds-button-group')[0].appendChild(li);    
    }
    window.onload=function() {
        setTimeout(function(){ addButton();}, 3000);
    }

</script>
New contributor
Srikanth V is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.