function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sean M 3Sean M 3 

Salesforce Mobile App Flow Redirect

Hi all,

I have implemented a custom button in Salesforce which when pressed triggers a flow:

/flow/POS_Order?AccountID={!Account.Id}&UniqueId={!$System.OriginDateTime}{!Account.Id}
&retURL=/apex/FlowRedirect?Id={!$System.OriginDateTime}{!Account.Id}


The flow creates the record then redirects to the record page via visualforce & Apex:
 
<apex:page controller="FlowRedirectController" action="{!FlowRedirectController}">
</apex:page>
 
public with sharing class FlowRedirectController {

    public Object FlowRedirectController() { 
        String unique_id = ApexPages.currentPage().getParameters().get('id');
        String url;
        
        if(unique_id == null){
            // Return Home if no ID 
            url = '/home/home.jsp';
            return new PageReference(url);
         } 
         
         else{
            Id orderId;
            try{
                // Get Order ID and set Redirect 
                orderId = [ SELECT  Name,
                                Unique_Flow_Identifier__c, 
                                Id  
                        FROM Order  
                        WHERE Unique_Flow_Identifier__c = :unique_id 
                        ORDER BY CreatedDate DESC   
                        LIMIT 1].Id;
                        
                // Redirect to ORder 
                url = '/' + String.valueOf(orderId);
                
            }catch(exception e){
                system.debug('FlowRedirectController.orderId is blank + ' + e);
            }
            // Did we find a Order? 
            if (orderId == null) {
            // Return Home if no ID 
            url = '/home/home.jsp'; 
            } 
        }
        
        return new PageReference(url);
    }
         
}

So it all works fine in Classic/Lightning however on the mobile app it redirects to login page when pressing button. Any ideas on how to fix this?

p.s. yes I have ticked the available for lightning box on vf page.