• Ana K. Bertuzzi
  • NEWBIE
  • 20 Points
  • Member since 2014
  • NA SFDC Admin
  • Lenovo


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi everyone,

I've created a VF page with calls a flow and a controller I created to pull a variable from the flow and use it in the finishLocation.

The thing is that now I tried to map this VF page overriding a custom object's "New" button, and realized that to do so, I needed to add the standardController to that object so I can see it when trying to change my button. Then I changed the controller to extension and added the following to my class:
public MyflowController(ApexPages.StandardController stdController) {}

The thing is that after this change, when I click the finish button, instead of landing in the URL of the Record Type (variable from the flow), the flow restarts in a loop.

Is there anything that I should change in the class? or the VF page?
I don't know what I should put between the curly brackets, so I left it empty. I wonder if that is the issue. I'm not actually "getting" anything from My_Tickets__c object.

This is the VF page:
<apex:page standardController="My_Ticket__c" extensions="MyflowController" TabStyle="My_Ticket__c">
   <br/>
   <flow:interview name="My_Tickets" interview="{!Myflow}" finishLocation="{!LinkID}" />
 </apex:page>

And the extension:
public class MyflowController {
 public MyflowController(ApexPages.StandardController stdController) {}
   public Flow.Interview.My_Tickets Myflow {get; set;}
   public String fullURL {get; set;}
   private String Instance = null;
   private void GetURL() {
      Instance = GetInstance(Instance);
      fullURL = 'https://' + Instance + '.salesforce.com/a1G/e?retURL=%2Fa1G%2Fo&RecordType=' + RTid() + '&ent=02I400000013Z1q';
      }
   public PageReference getLinkID() {
      GetURL();
      PageReference p = new PageReference (fullURL);
      p.setRedirect(true);
      return p;
      }
   public String RTid() {
      if (Myflow==null) return '';
      else return Myflow.varRecordType;
      }
   public String GetInstance(String Instance) {
      if (Instance == null) {
          List<String> parts = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
          if (parts.size() == 3) Instance = parts[0];
          else if (parts.size() == 5) Instance = parts[1];
          else Instance = null;
          } 
          return Instance;
       }
   }

Thanks for your help!

Ana
Hi,

I had an apex class that works if I write the instance I'm running. But if I try to change it to a "dynamic" instance, meaning that it detects the instance I'm logged in, I'm getting a "null"

I found a piece of code and I tried to make it work here, not sure what I'm doing wrong (cause I actually have no idea of coding). Please help!

I wonder if has anything to do with using both PageRefence and gerSalesforceBaseUrl in the same class.

Thank you!!

public class MyflowController {
   public Flow.Interview.Tickets Myflow {get; set;}
   public PageReference getLinkID() {
      String U1 = 'https://';
      String U2 = '.salesforce.com/a1G/e?retURL=%2Fa1G%2Fo&RecordType=';
      String U3 = '&ent=02I400000013Z1q';
      PageReference p = new PageReference (U1+Instance+U2+RTid()+U3);
      p.setRedirect(true);
      return p;
      }
   public String RTid() {
      if (Myflow==null) return '';
      else return Myflow.varRecordType;
      }
  
   private String Instance = null;
   private void GetURL(){
   Instance = GetInstance(Instance);
   }
   
   public String GetInstance(String Instance) {
      if (Instance == null) {
         List<String> parts = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
            if (parts.size() == 3) Instance = parts[0];
            else if (parts.size() == 5) Instance = parts[1];
            else Instance = null;
         } 
      return Instance;
      }
   }


How can I pass arguments from a flow to a URLFOR finishLocation? If I have an output variable in the flow, that is a 18-digit ID, can I reference it to build my URLFOR with something like {!flow.varID} ?

I'm trying to build something like

<apex:page>
   <flow:interview name="myFlow" finishLocation="{URLFOR('{!myFlow.varID}')"/>
<apex:page>

I've no experience building VF or Apex, so I would appreciate any help!

Kind regards,
Hi guys/gals,

Do you have any idea on how to obtain the Cloak of Adventure sweatshirt after completing 5 badges on trailheads?

Source: http://go.pardot.com/l/27572/2016-01-06/4wy4tn?utm_campaign=newyear-trailhead-sweatshirt

I haven't received any email address or notification about the completion after I had received 5 new badges on my profile. 

The sweetshirt looks really cool and I want to get it :D  Ty
 
Hi everyone,

I've created a VF page with calls a flow and a controller I created to pull a variable from the flow and use it in the finishLocation.

The thing is that now I tried to map this VF page overriding a custom object's "New" button, and realized that to do so, I needed to add the standardController to that object so I can see it when trying to change my button. Then I changed the controller to extension and added the following to my class:
public MyflowController(ApexPages.StandardController stdController) {}

The thing is that after this change, when I click the finish button, instead of landing in the URL of the Record Type (variable from the flow), the flow restarts in a loop.

Is there anything that I should change in the class? or the VF page?
I don't know what I should put between the curly brackets, so I left it empty. I wonder if that is the issue. I'm not actually "getting" anything from My_Tickets__c object.

This is the VF page:
<apex:page standardController="My_Ticket__c" extensions="MyflowController" TabStyle="My_Ticket__c">
   <br/>
   <flow:interview name="My_Tickets" interview="{!Myflow}" finishLocation="{!LinkID}" />
 </apex:page>

And the extension:
public class MyflowController {
 public MyflowController(ApexPages.StandardController stdController) {}
   public Flow.Interview.My_Tickets Myflow {get; set;}
   public String fullURL {get; set;}
   private String Instance = null;
   private void GetURL() {
      Instance = GetInstance(Instance);
      fullURL = 'https://' + Instance + '.salesforce.com/a1G/e?retURL=%2Fa1G%2Fo&RecordType=' + RTid() + '&ent=02I400000013Z1q';
      }
   public PageReference getLinkID() {
      GetURL();
      PageReference p = new PageReference (fullURL);
      p.setRedirect(true);
      return p;
      }
   public String RTid() {
      if (Myflow==null) return '';
      else return Myflow.varRecordType;
      }
   public String GetInstance(String Instance) {
      if (Instance == null) {
          List<String> parts = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
          if (parts.size() == 3) Instance = parts[0];
          else if (parts.size() == 5) Instance = parts[1];
          else Instance = null;
          } 
          return Instance;
       }
   }

Thanks for your help!

Ana
Hi,

I had an apex class that works if I write the instance I'm running. But if I try to change it to a "dynamic" instance, meaning that it detects the instance I'm logged in, I'm getting a "null"

I found a piece of code and I tried to make it work here, not sure what I'm doing wrong (cause I actually have no idea of coding). Please help!

I wonder if has anything to do with using both PageRefence and gerSalesforceBaseUrl in the same class.

Thank you!!

public class MyflowController {
   public Flow.Interview.Tickets Myflow {get; set;}
   public PageReference getLinkID() {
      String U1 = 'https://';
      String U2 = '.salesforce.com/a1G/e?retURL=%2Fa1G%2Fo&RecordType=';
      String U3 = '&ent=02I400000013Z1q';
      PageReference p = new PageReference (U1+Instance+U2+RTid()+U3);
      p.setRedirect(true);
      return p;
      }
   public String RTid() {
      if (Myflow==null) return '';
      else return Myflow.varRecordType;
      }
  
   private String Instance = null;
   private void GetURL(){
   Instance = GetInstance(Instance);
   }
   
   public String GetInstance(String Instance) {
      if (Instance == null) {
         List<String> parts = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.');
            if (parts.size() == 3) Instance = parts[0];
            else if (parts.size() == 5) Instance = parts[1];
            else Instance = null;
         } 
      return Instance;
      }
   }


How can I pass arguments from a flow to a URLFOR finishLocation? If I have an output variable in the flow, that is a 18-digit ID, can I reference it to build my URLFOR with something like {!flow.varID} ?

I'm trying to build something like

<apex:page>
   <flow:interview name="myFlow" finishLocation="{URLFOR('{!myFlow.varID}')"/>
<apex:page>

I've no experience building VF or Apex, so I would appreciate any help!

Kind regards,