Documentation

Salesforce Visualforce Example

AICopy for LLM

Complete Salesforce Implementation

This example shows how to add presentation sharing to a Salesforce Visualforce page.

Visualforce Page

<apex:page>
  <script>
    // UserView SDK compatibility flag for Lightning/Aura
    window.__upscopeFlags__ = ["aura_compatibility"];

    // ... rest of code found on https://userview.com/install

    // Pass additional metadata about the current context
    Upscope("updateConnection", {
      metadata: {
        recordId: "{!record.Id}",
        recordType: "{!record.RecordType.Name}"
      }
    });

    // Agent identification from Salesforce user
    var agentId   = '{!$User.Id}';
    var agentName = '{!JSENCODE($User.Name)}';

    function showLink() {
      Upscope("getPublicLink", {
        agentId: agentId,
        agentName: agentName
      }, function(link) {
        alert("Share this link with the customer: " + link);
      });
    }
  </script>

  <button onclick="showLink()">Get Public Link</button>

  <!-- Your presentation content here -->
  <apex:pageBlock title="Presentation">
    <!-- ... -->
  </apex:pageBlock>
</apex:page>

Key Points

  1. Aura Compatibility Flag: The window.upscopeFlags = ["aura_compatibility"] line ensures the SDK works correctly within Salesforce's Lightning framework.
  2. User Context: We use Visualforce merge fields ({!$User.Id}, {!JSENCODE($User.Name)}) to automatically get the current Salesforce user's information.
  3. JSENCODE: Always use {!JSENCODE()} for string values to prevent issues with quotes.
  4. Metadata: Pass relevant Salesforce record information via updateConnection to provide context in reports.