Loading

Salesforce Platform Flow: Opportunity Product TotalPrice Error

Fecha de publicación: Mar 31, 2026
Descripción
  • Opportunity Product:
    • Represents products added to Opportunities in Salesforce.
    • Includes details like quantity, unit price, and other pricing information.
    • Helps track what is being sold as part of an Opportunity.
  • TotalPrice:
    • A read-only formula field on Opportunity Products.
    • Automatically calculates as(UnitPrice - (UnitPrice * Discount)) * Quantity.
    • Cannot be directly updated but reflects the total value of the product line item.

This error typically happens in a record-triggered Flow(In Salesforce Sales Cloud) because the running user lacks the necessary Field-Level Security (FLS) to edit the UnitPrice or Quantity fields on the Opportunity Product object. The solution in this article is designed to bypass user permission issues entirely by having the record created in System Context. This avoids the need to grant specific FLS to the running user's profile or permission sets. 

What is Field Level Security? 

Field-Level Security (FLS) in Salesforce is a visual and data access control mechanism that allows administrators to restrict a user's ability to view and edit specific fields on a record, regardless of their object-level permissions. Unlike Record-Level Security, which determines which records a person can see, FLS determines what data within those records is accessible.

It is primarily managed through Profiles and Permission Sets, offering two settings: "Read-Only," which permits viewing but prevents modifications, and "Visible," which allows both viewing and editing. If a field is hidden via FLS, it is completely removed from page layouts, search results, reports, and list views for that user, ensuring that sensitive data like social security numbers or salary information remains confidential.

Because TotalPrice is a read-only, calculated field (Quantity x UnitPrice), the two resolutions often suggested—granting edit access to TotalPrice or running the flow in system mode—are not viable:

  1. You cannot grant edit access to a calculated field. This is standard behavior for calculated fields in Salesforce, as detailed in the official OpportunityLineItem object documentation

  2. A standard record-triggered Flow that runs before the record is saved cannot be configured to run in "System Context." For more details on this behavior, see the Help article: Flow Behavior for Read-Only Fields

The correct solution is to use a record-triggered Flow to launch a subflow that runs asynchronously in System Context to complete the record creation.

 

Solución

Resolution steps


The solution involves two parts: a main record-triggered flow and an autolaunched subflow that it calls.

Part 1: Create an Autolaunched Subflow

This flow will run in System Context and is responsible for creating the Opportunity Product record.

  1. Create a new Autolaunched Flow (No Trigger).

  2. In the Flow's start properties, under "Advanced," check the box to run the flow in System Context without Sharing—Access All Data.

  3. Create the necessary input variables to receive data from the main flow (e.g., input_OpportunityId, input_PricebookEntryId, input_Quantity, input_UnitPrice).

  4. Add a Create Records element to create the OpportunityLineItem record, mapping your input variables to the corresponding fields (OpportunityId, PricebookEntryId, Quantity, UnitPrice).

  5. Save and Activate this subflow.

 

Part 2: Create a Record-Triggered Main Flow

This flow will trigger when your initial criteria are met and will pass the required data to the subflow.

  1. Create a new Record-Triggered Flow that runs when your business process requires (e.g., when an Opportunity stage changes).

  2. Configure the flow to run Asynchronously. This is required to call a subflow that runs in System Context.

  3. Add a Subflow element to the canvas.

  4. Select the autolaunched subflow you created in Part 1.

  5. Map the necessary data from your triggering record or other sources into the subflow's input variables.

  6. Save and Activate the main flow.

Número del artículo de conocimiento

000390771

 
Cargando
Salesforce Help | Article