I have a flow from which I want to call a visualforcepage with some parameteres in the URL. The flow calls the invocable apex and the pagereference method but does not redirect to the url but does show the Screen test4 in the flow. What am I missing since I do not get redirected to an external URL. Why is the redirect method triggered but does not navigate to the given URL. I also do not have any exceptions.
Apex
public with sharing class NavigateToUrl {
//input details that comes to apex from flow
public class InputParameters {
@InvocableVariable
public Case CaseRec;
@InvocableVariable
public Zuora__Subscription__c SubRec;
}
//output details which goes from apex to flow
public class OutParameters {
@InvocableVariable
public String Test1;
@InvocableVariable
public String Test2;
}
@InvocableMethod(label = 'Navigate to URL' description = 'Navigate to URL')
public static void getInputParams(List<InputParameters> InParam) {
system.debug('Flow Invoked');
redirect(InParam[0].CaseRec.AccountId, InParam[0].CaseRec.id, InParam[0].CaseRec.ContactId, InParam[0].SubRec);
}
public static PageReference redirect(id AccountId, id CaseId, id Contactid, Zuora__Subscription__c Sub) {
system.debug('redirect started');
String baseUrl = string.valueOf(URL.getSalesforceBaseUrl());
String gotoUrl = baseUrl + 'apex/' + 'shop?accountid=' + AccountId + '&caseid=' + CaseId + '&contactid=' + ContactId + '&subrec=' + Sub;
PageReference newUrl = new PageReference(gotoUrl);
newUrl.setRedirect(true);
return newUrl;
}
}