• Sean M 3
  • NEWBIE
  • 40 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 6
    Replies
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.
Is it possible to setup fallback routing in Snap-ins chat similar to how it works in Live Agent:

https://developer.salesforce.com/docs/atlas.en-us.218.0.live_agent_dev.meta/live_agent_dev/live_agent_direct_to_agent_fallback_in_prechat_form.htm

I would like to route customer to an agent using choice in pre-chat form and if not available route back to a default button. However the documentation I have found doesn't let you do both:

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_set_routing_order.htm

https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_directtobutton_routing.htm

IF anyone has any ideas let me know.

Thanks
Good day,

I would like to create a custom lightning component on an Account page which displays details of the last Event logged on an account with a specific Event record type. Does anyone have any idea how I can acheive this?

Thanks
Good morning,

I have created a lightning component which runs a visual flow creating an Event record.

When the flow finishes I would like the page to be redirected to the created Event.

I have found a help topic with some example code but it would be great if someone could explain it ie. where would I add the created record id variable in my flow in this code so that it redirects?

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_using_flow_onfinish.htm
 
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "FINISHED") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "redirect") {
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,
               "isredirect": "true"
            });
            urlEvent.fire();
         }
      }
   }
}

Thank you
Good afternoon,

I am using an Apex Class coupled with a visualforce page to redirect a user to a Case record created from a Flow, when the Flow ends.

Code below:
 
public class flowController{
  // Instanciate the Flow for use by the Controller - linked by VF interview attribute
  public Flow.Interview.QuickCase flowInstance {get;set;}

  // Set the page reference accessor methods
  public PageReference finishLocation {
    get {
      PageReference pageRef = new PageReference('/' + newRecordId);
      pageRef.setRedirect(true);
      return pageRef;
      
    }
 
  }

  // Set the accessor methods for the flow output variable
  public String newRecordId {
    get {
      String strTemp = '';

      if(flowInstance != null) {
        strTemp = string.valueOf(flowInstance.getVariableValue('CreatedCaseId'));
      }
      return strTemp;
    }

  set { newRecordId = value; }
  }
}

I am having trouble writing a Test Class for this. Can anyone give me a starting point?

Many thanks
Good day developers

I have a Apex Class in Sandbox which redirects a user to a record created from a visual workflow with the help of a visualforce page:

public with sharing class FlowRedirectController {

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

        // Redirect to Order 
        String url = '/' + orderId;
        return new PageReference(url); 
        }
}


When deploying to production I am getting code coverage error. This is becasue I need to create an Apex Test Class however being new to Apex i'm unsure what I would need to test in this code... Is anyone able to help with this?

Thanks
Hi all,

I'm trying to add a previously created html email into a visualforce page but I keep getting the error below:

User-added image
Here is the start of my code (which i feel is causing the issue):

<messaging:htmlEmailBody >

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head>


I've tried adding </link> to line 158/159 but it doesn't make a difference.

Thanks
 
Good morning,

I have created a lightning component which runs a visual flow creating an Event record.

When the flow finishes I would like the page to be redirected to the created Event.

I have found a help topic with some example code but it would be great if someone could explain it ie. where would I add the created record id variable in my flow in this code so that it redirects?

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_using_flow_onfinish.htm
 
handleStatusChange : function (component, event) {
   if(event.getParam("status") === "FINISHED") {
      var outputVariables = event.getParam("outputVariables");
      var outputVar;
      for(var i = 0; i < outputVariables.length; i++) {
         outputVar = outputVariables[i];
         if(outputVar.name === "redirect") {
            var urlEvent = $A.get("e.force:navigateToSObject");
            urlEvent.setParams({
               "recordId": outputVar.value,
               "isredirect": "true"
            });
            urlEvent.fire();
         }
      }
   }
}

Thank you
Good afternoon,

I am using an Apex Class coupled with a visualforce page to redirect a user to a Case record created from a Flow, when the Flow ends.

Code below:
 
public class flowController{
  // Instanciate the Flow for use by the Controller - linked by VF interview attribute
  public Flow.Interview.QuickCase flowInstance {get;set;}

  // Set the page reference accessor methods
  public PageReference finishLocation {
    get {
      PageReference pageRef = new PageReference('/' + newRecordId);
      pageRef.setRedirect(true);
      return pageRef;
      
    }
 
  }

  // Set the accessor methods for the flow output variable
  public String newRecordId {
    get {
      String strTemp = '';

      if(flowInstance != null) {
        strTemp = string.valueOf(flowInstance.getVariableValue('CreatedCaseId'));
      }
      return strTemp;
    }

  set { newRecordId = value; }
  }
}

I am having trouble writing a Test Class for this. Can anyone give me a starting point?

Many thanks
Good day developers

I have a Apex Class in Sandbox which redirects a user to a record created from a visual workflow with the help of a visualforce page:

public with sharing class FlowRedirectController {

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

        // Redirect to Order 
        String url = '/' + orderId;
        return new PageReference(url); 
        }
}


When deploying to production I am getting code coverage error. This is becasue I need to create an Apex Test Class however being new to Apex i'm unsure what I would need to test in this code... Is anyone able to help with this?

Thanks
Hi all,

I'm trying to add a previously created html email into a visualforce page but I keep getting the error below:

User-added image
Here is the start of my code (which i feel is causing the issue):

<messaging:htmlEmailBody >

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head>


I've tried adding </link> to line 158/159 but it doesn't make a difference.

Thanks