Loading
Extend Salesforce with Clicks, Not Code
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
          End-to-end Example with Flow

          End-to-end Example with Flow

          In this Flow example, design and test the automation that sends a user’s information from Salesforce to the external employee banking system. Create the variables for user phone numbers, and combine different phone numbers into one piece of data. Then use the external service action to create the user.

          1. Define a named credential
            For this simplified example, use "legacy" Named Credentials. Instead of clicking New, select New Legacy from the dropdown menu next to the New button. For the named credential that your org uses to access the banking system, assign the Bank label. Assign a placeholder URL, such as https://api.example.com. Use example.com because you paste in the schema at registration time, instead of using a URL to point to an API spec.

            In the case where you use a URL, the named credential URL corresponds to the declared host of the API spec and one of its transfer protocol schemes or URL protocols. The URL can point to a different endpoint as long as it hosts the same external service. The base path is added to the named credential URL on callout.

          2. Register the employee banking system’s external service, using the steps described in Register an External Service as a guide. Use the BankService name and the Bank named credential, and then copy the schema from the “External Services API Spec Example 2”, found in the topic External Services OpenAPI 2.0 Schema.
          3. Click New Flow.
          4. Select Start From Scratch and click Next.
          5. Then, select Screen Flow and click Create.
            This example uses static values for simplicity. In contrast, a production flow with user data includes elements to get user records, store values to variables, and communicate these values to the external service.
          6. To handle the multiple phone numbers nested below the BankService_Phone value, add the two variable resources.
            1. Click Manager, and then click New Resource.
            2. For the resource type, select Variable.
            3. For the API name, enter WorkPhone.
            4. For the data type, select Apex-Defined.
            5. For the Apex class, select ExternalService__BankService_Phone.
              Adding a new resource of type Variable with name Workphone.
            6. Click Done.
            7. Repeat these steps using the API name CellPhone.
          7. Add the variable resource that acts as the array for the phone number values.
            1. Click New Resource.
            2. For the resource type, select Variable.
            3. For the API name, enter Phones.
            4. For the data type, select Apex-Defined, and select the Allow multiple values (collection) option.
            5. For the Apex class, select ExternalService__BankService_Phone.
              Adding a new resource, selecting the Allow multiple values checkbox.
            6. Click Done.
          8. Add the variable resource that stores the user’s name.
            1. Click New Resource.
            2. For the resource type, select Variable.
            3. For the API name, enter User.
            4. For the data type, select Apex-Defined.
            5. For the Apex class, select ExternalService__BankService_User.
            6. Click Done.
          9. Assign values to the work phone variable.
            1. From the Toolbox, click Elements.
            2. Drag an Assignment element to the canvas.
            3. For Label, enter Assign Work Phone, and let the API name autopopulate.
            4. Click Search variables, select WorkPhone, then select phone. The variable {!WorkPhone.phone} appears.
            5. For Value, enter 1234567890.
            6. Click Add Assignment.
            7. Click Search variables, select WorkPhone, then select typeofphone. The variable {!WorkPhone.typeofphone} appears.
            8. For Value, enter Work.
              Assign the variable values for the work phone.
            9. Click Done.
            10. Connect the Start element to this assignment element.
          10. Assign values to the cell phone variable.
            1. Drag an Assignment element to the canvas.
            2. For Label, enter Assign Cell Phone, and let the API name autopopulate.
            3. Click Search variables, select CellPhone, then select phone. The variable {!CellPhone.phone} appears.
            4. For Value, enter 0987654321
            5. Click Add Assignment.
            6. Click Search variables, select CellPhone, then select typeofphone. The variable {!CellPhone.typeofphone} appears.
            7. For Value enter Cell.
            8. Click Done.
            9. Connect the last element to this one.
          11. Assign multiple phone values to the single phone array variable.
            1. Drag an Assignment element to the canvas.
            2. For Label, enter Assign Phones, and let the API name autopopulate.
            3. Click Search variables then select Phones. The variable {!Phones} appears.
            4. Change the Operator to Add.
            5. For Value, select Workphone.
            6. Click Add Assignment.
            7. Click Search variables then select Phones again.
            8. Change the Operator to Add.
            9. For Value select Cellphone.
              Assign the two phone variables to add to the Phones array variable.
            10. Click Done.
            11. Connect the last element to this one.
          12. Assign the user values.
            1. Drag an Assignment element to the canvas.
            2. For Label, enter Assign User, and let the API name autopopulate.
            3. Click Search variables, select User, then id. The variable {!User.id} appears.
            4. For Value, enter 1234.
            5. Click Add Assignment.
            6. Click Search variables, select User, then name. The variable {!User.name} appears.
            7. For Value, enter Maria.
            8. Click Add Assignment.
            9. Click Search variables, select User, then phones. The variable {!User.phones} appears.
            10. For Value, select Phones.
              Assign the static values for id and name, and the phone array for phones.
            11. Click Done.
            12. Connect the last element to this one.
          13. To create users on the external bank system, add the action generated by your external service schema.
            1. Drag an Action element to the canvas.
            2. Filter the actions by type, and select External Service.
            3. Select postUser.
            4. For Label, enter Create a new user, and let the API name autopopulate.
            5. Next to >_user, toggle Included to include input values.
            6. From the lookup, select User.
              Assign the two phone variables to add to the Phones array variable.
            7. Click Done.
            8. Connect the last element to this one. Your canvas includes these elements.
              The elements created have been connected.
          14. Save and debug the flow. A successful debug includes the assignment and External Service callout.
            Debug result showing Assignment and Bankservice.postusers completed.
           
          Loading
          Salesforce Help | Article