Update and Deploy Permissions

Update a permission set to ensure that the function we create can access data in our Salesforce org. A permission set is a collection of settings and permissions that give users and apps access to various tools and data in Salesforce.

Update the Functions Permission Set 

When you connect your org to Salesforce Functions via the Functions Setup page, Salesforce creates a Functions permission set with minimal permissions. Update that permission set to give your function access to the Account object.

To update the Functions permission set, add the file force-app/main/default/permissionsets/Functions.permissionset-meta.xml, with contents:

1<?xml version="1.0" encoding="UTF-8"?>
2<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
3    <hasActivationRequired>true</hasActivationRequired>
4    <label>Functions</label>
5    <objectPermissions>
6        <allowCreate>true</allowCreate>
7        <allowDelete>false</allowDelete>
8        <allowEdit>true</allowEdit>
9        <allowRead>true</allowRead>
10        <modifyAllRecords>false</modifyAllRecords>
11        <object>Account</object>
12        <viewAllRecords>false</viewAllRecords>
13    </objectPermissions>
14</PermissionSet>

These permissions allow a running function in a compute environment connected to your org to access the Account object.

Deploy the Functions Permission Set 

Use project deploy start with the --ignore-conflicts flag to deploy your changes to the Functions permission set to your scratch org:

1sf project deploy start --ignore-conflicts --target-org MyOrgAlias
  • --ignore-conflicts Runs the deploy command even if conflicts exist.
  • --target-org A username or alias for the target org. Overrides the default target org.

Outputs:

1Deploying v59.0 metadata to test-1234dbzjb@example.com using the v60.0 SOAP API.
2Deploy ID: 0Af6t00000jWn
3Status: Succeeded | ████████████████████████████████████████ | 1/1 Components | Tracking: 1/1
4
5Deployed Source
6========================================================================================================
7| State   Name      Type          Path
8| ─────── ───────── ───────────── ──────────────────────────────────────────────────────────────────────
9| Created Functions PermissionSet force-app/main/default/permissionsets/Functions.permissionset-meta.xml

In VS Code, from the Command Palette, choose SFDX: Push Source to Default Scratch Org.

Tip

Product Retirement Announcement

Salesforce Functions is no longer available for purchase or renewal. To preserve the capabilities that Salesforce Functions provided to your org, deploy an alternative solution before your existing order term ends. See Salesforce Functions Retirement for more information on migrating your functions. Contact your Salesforce Account Executive for more information on Heroku.