> For the complete documentation index, see [llms.txt](https://docs.gridmate.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gridmate.io/advanced-guides/grid-setup/salesforce-classic-deployment.md).

# Salesforce Classic Setup

Run RelatedList and ListView grids on Salesforce Classic through Lightning Out and Visualforce.

GridMate can be deployed on Salesforce Classic. Only RelatedList and ListView grids are supported. To run GridMate on Classic, we use Salesforce [Lightning out](https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lightning_out).

## Lightning application setup

To run the Lightning out on Classic, a lightning app **VFListViewDataGridApp** should be created with the markup below.

```markup
<aura:application extends="ltng:outApp" >
    <aura:dependency resource="gmpkg:VFListViewDataGridComponent"/>
    <aura:dependency resource="markup://force:showToast" type="EVENT"/>
    <aura:dependency resource="markup://force:refreshView" type="EVENT"/>
</aura:application>
```

## Visualforce page setup

Create a Visualforce page to wrap GridMate component using the Lightning out technology.

```markup
<apex:page controller="VFListViewDataGridController"
           showHeader="true"            
           sidebar="false">
    <apex:includeLightning />
    
    <div id="workbench" />
    
    <script>
    $Lightning.use("{!lightningApp}", function() {        
        //prepare attributes
        let attributes = JSON.parse('{!attributes}' || '{}');
        attributes = Object.assign(attributes, {
            "aura:id": "listViewGrid",
            "relatedObjectName" : "{!relatedObjectName}",
            "listViewName" : "{!listViewName}",
            "canFilter": true            
        });
        
        //create the data grid
        $Lightning.createComponent("gmpkg:VFListViewDataGridComponent",
                                   attributes,
                                   "workbench",
                                   function(component) {
                                       $A.eventService.addHandler({
                                           event: 'force:showToast',
                                           handler: function(event) { 
                                               let toast = component.find("toast");
                                               toast.showToast(event.getParams());
                                           }
                                       });
                                   });
    });        
    </script>
</apex:page>
```

We have also to implement the Visualforce controller with its unit test class

```java
/***
* @author Hicham El Mansouri@GridMate
* @date 12/2019
* @description DataGrid controller class for VFListViewDataGrid.
*/
public with sharing class VFListViewDataGridController {
    private final String lightningApp;
    private final String relatedObjectName;
    private final String listViewName;
    private final String attributes;
    
    public VFListViewDataGridController() {
        lightningApp = ApexPages.currentPage().getParameters().get('c__lightningApp');
        relatedObjectName = ApexPages.currentPage().getParameters().get('c__object');
        attributes = ApexPages.currentPage().getParameters().get('c__attributes');
        
        listViewName = getLastUsedListView(relatedObjectName);
    }

    private static String getLastUsedListView(String objName)
    {
        try{
            RecentlyViewed recentItem = [Select Id, Name From RecentlyViewed  
                                         Where Type='ListView' Order by LastViewedDate Desc Limit 1];
            
            ListView listView = [Select Id, Name, DeveloperName From ListView 
                                 Where SobjectType=:objName And Name=:recentItem.Name Limit 1];
            
            return listView.DeveloperName;
        }        
        catch(Exception ex){
            System.debug(ex.getStackTraceString());
            return null;
        }           
    }
    
    public String getRelatedObjectName() {
        return relatedObjectName;
    }
    
    public String getAttributes() {
        return attributes;
    }
    
    public String getListViewName() {
        return listViewName;
    }       
    
    public String getLightningApp() {
        return lightningApp;
    } 
}
```

```java
/***
* @author Hicham El Mansouri@GridMate
* @date 12/2019
* @description DataGrid controller class for VFListViewDataGrid.
*/
@isTest
public class VFListViewDataGridControllerTest {
    static testMethod void testGetLastUsedListView(){
        ApexPages.currentPage().getParameters().put('c__lightningApp', 'c:VFListViewDataGridApp');
        ApexPages.currentPage().getParameters().put('c__object', 'Account');
        ApexPages.currentPage().getParameters().put('c__attributes', '%7B"canCreate"%3A+true%2C"canClone"%3A+true%7D');
        
        VFListViewDataGridController c = new VFListViewDataGridController();
        
        String lastUsed = c.getListViewName();
        if(lastUsed == null){System.assert(lastUsed == null);}
        else{ System.assert(lastUsed != null);}
        
        String relatedObjectName = c.getRelatedObjectName();
        System.assert(relatedObjectName != null);
        
        String attributes = c.getAttributes();
        System.assert(attributes != null);
        
        String lightningApp = c.getLightningApp();
        System.assert(lightningApp != null);
    }
}
```

## Mass Edit button setup

To trigger the mass edit Visualforce page, we have to configure a link on the targeted object.

![](https://4046919449-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEsSbGy_U_OhthKUpxu%2F-MFFC0b29nEm7BzPxo6U%2F-MFFI7PaKOEbmyK7lCLv%2FScreenshot%202020-08-21%20at%2011.14.08.png?alt=media\&token=5bc11831-0237-4a9c-9401-d8431f629155)

```javascript
{! URLFOR( "/apex/VFListViewDataGridPage?", null, 
[
  c__lightningApp='c:VFListViewDataGridApp',
  c__object='Account',
   c__attributes='{"canCreate":true,"canClone":true,"canFilter":true}'
]
)}
```

{% hint style="info" %}
Mass Edit can be enabled on any object by duplicating the link below and changing the **c\_\_object** parameter only.
{% endhint %}

The link should be added to the list of actions on a ListView.

![](https://4046919449-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEsSbGy_U_OhthKUpxu%2F-MFFC0b29nEm7BzPxo6U%2F-MFFJ9zFHT7IbVRhwcg4%2FScreenshot%202020-08-21%20at%2011.18.56.png?alt=media\&token=a515047f-5b8c-44d9-ac37-52cae105031d)

## Remote Site setup

GridMate uses API to fetch the ListView's metadata. Visualforce URL should be added to Remote Site Settings. See below :point\_down:

![Remote Site settings](https://4046919449-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEsSbGy_U_OhthKUpxu%2F-MFFC0b29nEm7BzPxo6U%2F-MFFKD-72KGmmCcqqHJW%2FScreenshot%202020-08-21%20at%2011.23.37.png?alt=media\&token=e44af774-7315-4ae5-9939-0253c7e86a0f)

## Next steps

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Grid - Mass Edit Button</strong></td><td>Open any list view as an editable GM - ListView Grid.</td><td><a href="/advanced-guides/grid-actions/mass-edit-setup.md">Grid - Mass Edit Button</a></td></tr><tr><td><strong>List View Grid</strong></td><td>Display any Salesforce list view in a grid with search and inline edit.</td><td><a href="/product-tour/grids/list-view-grid.md">List View Grid</a></td></tr><tr><td><strong>GM - ListView Grid</strong></td><td>Every property of the component.</td><td><a href="/package-reference/components-library/gm-listview-grid.md">GM - ListView Grid</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gridmate.io/advanced-guides/grid-setup/salesforce-classic-deployment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
