Button: {!URLFOR(IF($Site.prefix == '/s','/apex/dfsle__gendocumentgenerator', $Site.Prefix +'/apex/dfsle__gendocumentgenerator'), null, [sId = Opportunity.Id, templateId = ''+Opportunity.Gen_Template_ID_Reference__c+'', recordId = Opportunity.Id, title = 'Send with DocuSign'])}", "answerCount": 1, "upvoteCount": 0, "datePublished": "2022-12-13T23:47:48.000Z", "author": { "@type": "Person", "name": "Kevin Grothe", "url": "https://trailblazers.salesforce.com/profileView?u=0053A00000EehOlQAJ", "affiliation": { "@type": "Organization", "name": "RockBot" } }, "suggestedAnswer": [ { "@type": "Answer", "text": "Hi Kevin, Try adding debug statements to your controller and check if the sendWithRedirect method is being called. You can use System.debug() to log messages. Make sure that you are passing the correct parameters to the method and that they have values. Make sure that the Visualforce page (VF_Redirect) is accessible and not restricted by permissions or security settings. Thanks.", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007T429tSAB", "datePublished": "2023-10-05T12:01:40.000Z", "author": { "@type": "Person", "name": "Ashwini Garwandha", "url": "https://trailblazers.salesforce.com/profileView?u=0054S000002svOUQAY", "affiliation": { "@type": "Organization", "name": "Salesforce" } } } ] } } Skip to main content
Kevin Grothe (RockBot) ha fatto una domanda in #Apex
Hello, 

I'm attempting to launch a visualforce page from a screenflow, attempting to mimic the functionality of detail page button but inside the flow. The visualforce page has a controller that is supposed to retrieve and set the parameters. Then the controller creates a PageReference that inserts the parameters and returns a URL to redirect the user. However, I can't get my PageReference method inside the controller to execute, it just stops after assigning the parameters to variables. Any help would be amazing. 

Controller:

public inherited sharing class Screen_Flow_Redirect {

public String title { get; set; }

public String recordId { get; set; }

public String sId { get; set; }

public Id templateId { get; set; }

public Screen_Flow_Redirect() {

title = 'Send with Docusign';

recordId = ApexPages.currentPage().getParameters().get('recordId');

sId = ApexPages.currentPage().getParameters().get('sId');

templateId = ApexPages.currentPage().getParameters().get('templateId');

System.debug('This is the sId:::' + sId);

}

public String sendWithRedirect(Id templateId, String sId, String recordId, String title) {

PageReference pr = Page.VF_Redirect;

pr.getParameters().put('sId',sId);

pr.getParameters().put('templateId',templateId);

pr.getParameters().put('recordId', recordId);

pr.getParameters().put('title', title);

return pr.getUrl();

}

}

Visualforce Page:

<apex:page controller="Screen_Flow_Redirect" showHeader="true">

<apex:slds />

<script src="/soap/ajax/55.0/connection.js" />

<script type="text/javascript">

function init() {

redirectUrl = "{!URLFOR(IF($Site.prefix == '/s','/apex/dfsle__gendocumentgenerator',$Site.Prefix +'/apex/dfsle__gendocumentgenerator'), null,[sId=sId,templateId=templateId,recordId=recordId,title=title])}";

if (sforce && sforce.one) {

sforce.one.navigateToURL(redirectURL);

} else {

document.location.assign(redirectURL);

}

}

init();

</script>

</apex:page>

Button:

{!URLFOR(IF($Site.prefix == '/s','/apex/dfsle__gendocumentgenerator',

$Site.Prefix +'/apex/dfsle__gendocumentgenerator'), null,

[sId = Opportunity.Id, templateId = ''+Opportunity.Gen_Template_ID_Reference__c+'',

recordId = Opportunity.Id, title = 'Send with DocuSign'])}

 
1 risposta
  1. 5 ott 2023, 12:01
    Hi Kevin,

    Try adding debug statements to your controller and check if the sendWithRedirect method is being called. You can use System.debug() to log messages.

    Make sure that you are passing the correct parameters to the method and that they have values.

    Make sure that the Visualforce page (VF_Redirect) is accessible and not restricted by permissions or security settings.

    Thanks.