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');
        String accountParam =Apexpages.currentPage().getParameters().get('inpAccountID');
        //String accountParam = Site.getCurrentSiteUrl();
        ReturnVariables urlAccountId = new ReturnVariables();
        urlAccountId.accountId = accountParam;
        return returnVariablesList;

    public class ReturnVariables {
        public String accountId;

1 Answer 1


If you're just looking to pass variables into your Flow from the URL you shouldn't need any Apex code at all. If you have exposed the inpAccountId variable as an input variable, you should be option to specify values for those input variables. To populate those from the URL, you simply need to reference them with the following format:


An example of this would look like this: enter image description here

Where Key and Id are both URL parameters.

The documentation for this is available here: https://help.salesforce.com/s/articleView?id=sf.flow_distribute_external_community.htm&type=5

Also this blog post provides an example: https://salesforcetime.com/2022/11/14/how-to-pass-parameters-to-flows-in-experience-sites/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .