Search code examples
salesforce-lightningsalesforce-flow

How to use Salesforce Field Service Mobile Flow in app AND lightning web


I am designing a Field Service Mobile Flow for a Salesforce instance (release Winter '23 Patch 17.7) using the Field Service Lightning package to manage technicians with service appointments in the field. The flow will be presented to technicians in the field in the Salesforce Field Service Mobile (FSM) app on iOS devices.

This flow will be added as quick action on a specific object, e.g. a ServiceAppointment object. Hence it will be presented in the app to the technician to execute the flow. Additionally, quick actions are also shown in the lightning web view of the object, enabling to execute the same flow, even though it is a Field Service Mobile Flow.

The challenge occurs, when trying to use the Id of the calling record (here the ServiceAppointment) as input.

The FSM app provides the Id of the calling object as variable Id, while a flow executed from the lightning web view passes the variabled recordId.

How can one handle this to use the same Field Service Mobile Flow in the FSM app AND in web lightning view.


Solution

  • I added a subflow to retrieve the origin of the call, differentiating between the two input variables, and setting an output variable current_record_id accordingly.

    FS Mobile Flow call orign ids


    The condition checks, wether the input variable Id or the input variable recordId is set and assigns the output variable current_record_id accordingly.

    Condition outcome for FieldService Mobile

    Condition outcome for Salesforce Web


    You might already spot the actual challenge. The behaviour of not-provided variables is different in the FSM app, the web call and (to make it even worse) when debugging the flow.

    The following table shows my checks for the different origins and the resulting outcome (which check proofs as true)

    Path Call flow from outcome
    1 FSM app (provides Id) recordId is null
    2 Lightning Web (provides recordId) Id is empty
    3 Flow designer debug (recordId provided) Id is null
    4 Flow designer debug (Id provided) recordId is null

    hence we have to explicitly check for null OR empty for the missing variable.


    Now you can use four Field Service Mobile Flow via a quick action the Field Service Mobile App, in Salesforce Lightning and in the Flow Debugger successfully.