Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Agentforce Field Service and Operations
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Example: Create a Field Service Product Order with Agentforce

          Example: Create a Field Service Product Order with Agentforce

          Placing a product order can be cumbersome. With Agentforce, you can create a flow that triggers an agent subagent to place the product order for you.

          Required Editions

          Einstein generative AI is available in Lightning Experience. Setup for Einstein generative AI is available in Lightning Experience.
          Available in all enhanced Messaging channels. View required editions.
          The Field Service core features and managed package are available in Enterprise, Performance, Unlimited, and Developer Editions.
          For purchasing options, contact your Salesforce account executive.
          User Permissions Needed
          To build subagents and actions: Manage Agentforce Default Agent
          Asking the AI agent to place a product order and seeing it created in the system

          Step 1: Create a Flow

          Create a flow that generates a product order, which is represented in the system as a product request and a product request line item.

          1. From Setup, in the Quick Find box, enter Process Automation, and then select Flows.
          2. Click New Flow.
          3. Select Start From Scratch and click Next.
          4. Select Autolaunched Flow (No Trigger) and click Create.
          5. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter inputProductName.
            3. For Description, enter The name of the requested product.
            4. For Data Type, select Text.
            5. Select Available for Input.
          6. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter inputNeedDate.
            3. For Description, enter The date when the order must be placed.
            4. For Data Type, select Date.
          7. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter inputNeedDateText.
            3. For Description, enter The date entered by the user.
            4. For Data Type, select Text.
            5. Select Available for Input.
          8. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter inputQuantity.
            3. For Description, enter The requested quantity.
            4. For Data Type, select Number.
            5. For Decimal Places, enter 0.
            6. For Default Value, enter 1.
            7. Select Available for Input.
          9. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter inputWorkOrderNumber.
            3. For Description, enter The work order number that the product request is for.
            4. For Data Type, select Text.
            5. Select Available for Input.
          10. From the Toolbox, click New Resource.
            1. For Resource Type, select Variable.
            2. For API Name, enter outputInfo.
            3. For Description, enter Additional information.
            4. For Data Type, select Text.
            5. Select Available for Output.
          11. This step isn’t required, but it’s a recommended practice to ensure that the flow can handle imperfect input and provide clear error messages. From the Toolbox, click New Resource.
            1. For Resource Type, select Formula.
            2. For API Name, enter formulaValidateDate.
            3. For Description, enter Validates the date.
            4. For Data Type, select Boolean.
            5. For Formula, enter:
              REGEX({!inputNeedDateText}, '((?:19|20)\\d\\d)-(0?[1-9]|1[012])-([12][0-9]|3[01]|0?[1-9])')
            6. To validate the formula, click Check Syntax.
          12. This step isn’t required, but it’s a recommended practice to ensure that the flow can handle imperfect input and provide clear error messages. From the Toolbox, click New Resource.
            1. For Resource Type, select Formula.
            2. For API Name, enter formulaBadDateOutput.
            3. For Description, enter Error message that the user sees if the date isn’t valid.
            4. For Data Type, select Text.
            5. For Formula, enter:
              {!inputNeedDateText} + ' has the wrong format. Enter the date as YYYY-MM-DD and try again.'
            6. To validate the formula, click Check Syntax.
          13. This step isn’t required, but it’s a recommended practice to ensure that the flow can handle imperfect input and provide clear error messages. From the Toolbox, click New Resource.
            1. For Resource Type, select Formula.
            2. For API Name, enter formulaConvertDate.
            3. For Description, enter Converts the date entered by the user to the format used in the system.
            4. For Data Type, select Date.
            5. For Formula, enter:
              DATEVALUE({!inputNeedDateText})
            6. To validate the formula, click Check Syntax.
          14. In a sequential flow line without branching, add elements to the flow. Add a Get Records element.
            1. For Label, enter Get Product.
            2. For Description, enter Retrieves the product item by name passed to the flow.
            3. For Data Source, select Salesforce Object
            4. For Object, select Product.
            5. Fill in the condition requirements.
              Field: Name
              Operator: Equals
              Value: {!inputProductName}
          15. Add a Get Records element.
            1. For Label, enter Get Service Resource.
            2. For Description, enter Retrieves the ID of the mobile worker that’s running the flow.
            3. For Data Source, select Salesforce Object
            4. For Object, select Service Resource.
            5. Fill in the condition requirements.
              Field: RelatedRecordId
              Operator: Equals
              Value: {!$User.Id}
          16. Add a Get Records element.
            1. For Label, enter Get Work Order.
            2. For Description, enter Retrieves a work order by the number passed to the flow.
            3. For Data Source, select Salesforce Object
            4. For Object, select Work Order.
            5. Fill in the condition requirements.
              Field: Work Order Number
              Operator: Contains
              Value: {!inputWorkOrderNumber}
          17. To create a product request based on the flow inputs, add a Create Records elements to the flow.
            1. For Label, enter Create Product Request.
            2. For How to Set Record Field Values, select Manually.
            3. For Object, select Product Request.
            4. Add these fields and field values.
              Description: Requested by Technician
              NeedByDate: inputNeedDate
              ShipmentType: Pick Up
              Status: Submitted
              WorkOrderId: {!Get_Work_Order.Id}
          18. To create the required product request line items based on the flow inputs, add a Create Records elements to the flow.
            1. For Label, enter Create PRLI.
            2. For How to Set Record Field Values, select Manually.
            3. For Object, select Product Request Line Item.
            4. Add these fields and field values.
              ParentId: {!Create_Product_Request}
              Product2Id: {!Get_product.Id}
              QuantityRequested: inputQuantity
              QuantityUnitOfMeasure: Each
              WorkOrderId: {!Get_Work_Order.Id}
          19. To retrieve the created product request to pass as output of the flow in the Return the Info assignment, add a Get Records elements to the flow.
            1. For Label, enter Get New Product Request.
            2. For Data Source, select Salesforce Object
            3. For Object, select Product Request.
            4. Fill in the condition requirements.
              Field: Id (Product Request ID)
              Operator: Equals
              Value: {!Create_Product_Request}
          20. To retrieve the created product request line items to pass as output of the flow in the Return the Info assignment, add a Get Records elements to the flow.
            1. For Label, enter Get New PRLI.
            2. For Data Source, select Salesforce Object
            3. For Object, select Product Request Line Item.
            4. Fill in the condition requirements.
              Field: Id (Product Request Line Item ID)
              Operator: Equals
              Value: {!Create_PRLI}
          21. From the Toolbox, click New Resource.
            1. For Resource Type, select Formula.
            2. For API Name, enter formulaOutput.
            3. For Data Type, select Text.
            4. For Formula, enter:
              'Product Request# ' + {!Get_New_Product_Request.ProductRequestNumber} + ' was created for product: ' + {!Get_Product.Name} + '. ' + text({!Get_New_PRLI.QuantityRequested}) + ' were requested and expected by ' + text({!Get_New_Product_Request.NeedByDate})
            5. To validate the formula, click Check Syntax.
          22. Add an Assignment element to the flow.
            1. For Label, enter Return the Info.
            2. Enter these conditions.
              Field: outputInfo
              Operator: Equals
              Value: formulaOutput
          23. To ensure that the input text date is a valid date, add a Decision element at the top of the flow.
            1. For Label, enter Is the date format valid?
            2. The top outcome is what happens if the date is valid. For Label, enter Yes.
            3. Enter these conditions.
              Resource: formulaValidDate
              Operator: Equals
              Value: True
            4. For Default Outcome, change the label to No.
          24. In the Yes branch, add an Assignment element.
            1. For Label, enter Valid Date.
            2. Enter these conditions.
              Variable: inputNeedDate
              Operator: Equals
              Value: formulaConvertDate
          25. In the No branch, add an Assignment element. If the date isn’t valid, the flow returns an error message.
            1. For Label, enter Invalid Date.
            2. Enter these conditions.
              Variable: outputInfo
              Operator: Equals
              Value: formulaBadDateOutput
            3. Click the Assignment element and select Connect to element.
            4. Select the End element.
          26. Save the flow.
            1. For Label, enter Create Product Request.
            2. For Description, enter Flow that generates a Product Request and a Product Request Line Item based on the needed date, product name, quantity, and work order number.
          27. Click Activate.

          If you’ve used the suggested labels, the flow looks like this.

          Example flow

          Step 2: Create an Agent Action

          Set up an agent action that triggers the Create Product Request flow that you created.

          1. From Setup, in the Quick Find box, enter Agent Studio, and then select Agent Actions.
          2. Click New Agent Action.
          3. For Reference Action Type, select Flow.
          4. For Reference Action, select Create Product Request.
          5. For Agent Action Label, enter Order Product.
          6. For API Name, enter OrderProduct.
          7. Click Next.
          8. For Agent Action Instructions, enter:
            This action is triggered by phrases like “order product” or “order product request” or “product request”. The user will be providing the work order number, the product description, the quantity required, and the needed date.
            Note
            Note Instructions help your agent understand when to use a given action. The more specific the instructions are, the better the action performs and the more reliable results you receive.
          9. The action pulls the inputs from the flow that you specified. All you have to do is add the details.
            1. For inputNeedDateText, select Collect data from user and enter these instructions.
              This is the date that the product is needed by. Its format is YYYY-MM-DD. If only the month name is provided, convert this to the last day of that month. If no date is provided by the user, use the current date plus 7 days. Convert Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday into actual dates, with YYYY-MM-DD as the format.
            2. For inputProductName, select Collect data from user and Require Input. Then, enter these instructions.
              This is the product name. It might be referred to as the product, the part, the item. It might be several words, for example, Small Battery.
            3. For inputQuantity, select Collect data from user and enter these instructions.
              This is the quantity required. It’s an integer. If no value is provided, then use 1 for the value.
            4. For inputWorkOrderNumber, select Collect data from user and Require Input. Then, enter these instructions.
              This is the work order number. It might be referred to as the WO or the WO num or the WO number. It will be in the form of an integer and it may have leading zeroes. Important: Prepend the number with the necessary zeros to achieve the length of 8 digits.
          10. Add the output details.
            1. For outputInfo, select Show in Conversation and enter these instructions.
              This is a text field returned from the flow. It’s a simple text string. Use a casual tone in the response. If the word error is present, then display this field in bold. Otherwise precede the text with a thumbs up emoji. If a date is present, present it in MM DD format.
          11. Click Finish.

          Step 3: Create a Subagent

          1. From Setup, in the Quick Find box, enter Agent Studio, and then select Agents.
          2. Click the name of your agent.
          3. Click Open in Builder.
          4. Click the arrow and select New Subagent.
          5. Fill in the information for the subagent and click Next.
          6. Select the Agent Action that you created and click Finish.

          Step 4: Verify on Desktop

          1. From the App Launcher, find and select Field Service.
          2. Click the Agentforce icon in the top right corner.
          3. Ask Agentforce to order a product for you. Make sure you provide the number of the work order, the product order, and the due date.
            The response indicates that the action was executed and the product request was created for you.
            Product order on desktop
          4. Search for the product request number to verify that everything went smoothly in the system.
            Product Order in the Salesforce
          5. Test out the errors by entering an invalid date such as 2025-dfgs-24 and see whether the flow generates an error message.

          Step 5: Verify on the Field Service Mobile App

          1. Make sure that you’re defined as a mobile worker in the Salesforce org and have access to the Field Service mobile app. See Give Users Access to the Field Service Mobile App.
          2. Open the Field Service mobile app.
          3. Tap Actions.
          4. Ask Agentforce to order a product for you. Make sure you provide the number of the work order, the product order, and the due date.
            Agentforce creates the product request for you with the required details.
            Product order request on mobile
           
          Loading
          Salesforce Help | Article