I have a screen flow that displays the accounts that a user is associated with. There are hyperlinks to display the name and when clicked opens a new browser with https://my_custom_url/pocdiy2/s/account-chooser?inpAccountID=0013t00001tYSjQAAW
inpAccountID
depend on the Account that the users clicks.
I have created an out of box page in the community with a another screen flow to display the Account Name and Id of one being passed in the parameter inpAccountID
.
I have added an Apex action class to get the url and id from the current page.-This is where I am running into problems because I don't know how to get the current url, especially the parameters.
ERROR: 'Attempt to de-reference a null object'
for the ApexPages code line
Can someone please help me out?
public with sharing class AccountChooser {
@InvocableMethod(label='Get accountid from url' description='Get account id when Account Chooser is used')
public static List<ReturnVariables> AccountChooser() {
List<ReturnVariables> returnVariablesList = new List<ReturnVariables>();
System.debug('Test here first');
System.debug(URL.getSalesforceBaseUrl().toExternalForm());
String accountParam =Apexpages.currentPage().getParameters().get('inpAccountID');
//String accountParam = Site.getCurrentSiteUrl();
ReturnVariables urlAccountId = new ReturnVariables();
urlAccountId.accountId = accountParam;
returnVariablesList.add(urlAccountId);
return returnVariablesList;
}
public class ReturnVariables {
@InvocableVariable
public String accountId;
}
}