Set up Permissions for Accessing Salesforce

We need to ensure that the function we create has the appropriate permissions to access data in our Salesforce org. This is done using a permission set. 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, a "Functions" permission set is automatically created, with minimal permissions. You'll update that permission set to give your Function access to the Account object.

Update the Functions permission set by adding the file force-app/main/default/permissionsets/Functions.permissionset-meta.xml, with contents:

This ensures that a running Function in a compute environment connected to your org has access to Account. It also ensures read access to FunctionInvocationRequest, which is needed for invoking Functions from your org.

Deploy the Permission Set

Use force:source:push with the "force overwrite" flag to push your changes to the Functions permission set to your scratch org: