Gmail Grid Integration

The Gmail Grid integration allows Salesforce users to view, search, filter, and inspect email messages and thread histories from Gmail directly inside AppColab Grid without synchronizing email bodies into Salesforce custom objects.

Gmail Live Grid Preview


What’s Deployed

Component Name Purpose
Named Credential Gmail Connects to https://gmail.googleapis.com via Google_APIs External Credential
External Credential Google_APIs Shared Google OAuth 2.0 credential
Apex Client GmailClient.cls REST client supporting listMessages, getMessage, listThreads, getThread
Apex Data Provider GmailGridDataProvider.cls Implements appcg.GridDataProviderV1 for message feeds, search queries, and sender filtering
Permission Set Integration_Admin Grants access to Google_APIs → Google_User principal

One-Time Manual Setup

1. Enable Gmail API in Google Cloud

  1. In the Google Cloud Console, open your Google integration project.
  2. Go to APIs & Services → Library.
  3. Search for and enable Gmail API.
  4. In OAuth consent screen → Scopes, add:
    • https://www.googleapis.com/auth/gmail.readonly
  5. Save changes.

Google Cloud Gmail API Setup


2. Configure Credentials in Salesforce Setup

Salesforce connects securely to Gmail using External Credentials and Named Credentials. If you have already configured Google_APIs for Google Sheets or GA4, you only need to create the Gmail Named Credential (Step 2.2).

2.1 Create the External Credential (if not already created)

  1. Go to Setup (gear icon ⚙️ → Setup).
  2. In the Quick Find box, enter Named Credentials and select Named Credentials.
  3. Click the External Credentials tab → click New:
    • Label: Google APIs
    • Name: Google_APIs
    • Authentication Protocol: OAuth 2.0
    • Authentication Provider: Select your Google Auth Provider (e.g. Google_OAuth).
    • Click Save.
  4. Under the Principals section on the detail page, click New:
    • Parameter Name: Google_User
    • Sequence: 1
    • Click Save.
  5. On the Google_User row, click the dropdown arrow → click Authenticate.
  6. Sign in with the Google account for your Gmail integration and approve permissions. (Status will update to Configured).

Google APIs External Credential Setup

2.2 Create the Named Credential

  1. Click the Named Credentials tab (next to External Credentials) → click New:
    • Label: Gmail
    • Name: Gmail
    • URL: https://gmail.googleapis.com
    • External Credential: Select Google APIs
    • Generate Authorization Header: Checked
    • Allow Formulas in HTTP Header: Checked
  2. Click Save.

Gmail Named Credential Setup


3. Assign Permission Set Access

  1. In Salesforce Setup, enter Permission Sets in Quick Find.
  2. Select Integration Admin (or Appcolab Grid Admin).
  3. Click External Credential Principal Access → click Edit.
  4. Add Google_APIs - Google_User to Enabled External Credential Principals.
  5. Click Save and verify the permission set is assigned to your Salesforce users.

Creating a Gmail Grid Definition

  1. In Salesforce, open AppColab Grid app → Grid Definitions tab → click New Grid Definition.
  2. Fill in:
    • Grid Settings Name: Gmail_Inbox_Grid
    • Grid Label: Recent Gmail Messages
    • Is Active?: Checked
    • Data Provider Class: GmailGridDataProvider
    • Data Provider Configuration:
      {
        "query": "is:inbox",
        "maxResults": 25
      }
      

      Tip: You can use standard Gmail search operators like "query": "from:acme.com" or "query": "has:attachment". Because message details are fetched via individual API calls, keeping maxResults at 20–25 ensures lightning-fast grid load times while staying well within Salesforce callout limits.

  3. Click Save & Next → proceed to Preview.
  4. Your recent emails load live with Subject, From, Date, and Snippet!

Gmail Grid Definition


Supported Grid Features

Column Data Type Description
Subject TEXT Email subject line
From EMAIL Sender name and email address
Snippet TEXT Plaintext email preview snippet
Date DATETIME Message timestamp
Thread ID TEXT Gmail conversation thread ID
Labels TEXT Applied Gmail labels (e.g. INBOX, UNREAD, STARRED)

Troubleshooting

  • 403 Forbidden / Access Not Configured: Ensure the Gmail API is enabled in your Google Cloud Console project.
  • 401 Unauthorized: Re-authenticate the Google_User principal in Salesforce Setup → Named Credentials → External Credentials → Google APIs.