0

I am using list view button to call lightning component. I wanted to fetch the list view Id from URL on click of list view button and pass it to lightning component. Is there any way I can fetch the parameter "filterName"(List View Id) from URL using VF Page. I tried using

{!$CurrentPage.parameters.filterName}

But, After clicking the List View Button it is returning null. Here I am using List View Button just to open the Lightning Modal Window. And, as per my requirement If I choose a list view and hit the button the newly created record should visible to that specific list view. Please refer the comments and help me with this issue...

Thanks in Advance...

VF Page

<apex:page >
    <apex:includeLightning />
    <apex:slds />
    
    <div id="loading">
        <div role="status" class="slds-spinner slds-spinner_large slds-spinner_brand">
            <span class="slds-assistive-text">Loading...</span>
            <div class="slds-spinner__dot-a"></div>
            <div class="slds-spinner__dot-b"></div>
        </div>
    </div>
    
    <div id="lightning"/>
    
    <script>
    var filterId = "{!$CurrentPage.parameters.filterName}";
    $Lightning.use("c:VDLP_NewCampaignApplication", function() {
        $Lightning.createComponent("c:VDLP_NewCampaignComponent", 
                                   {"filterName" : filterId}, 
                                   "lightning", 
                                   function(cmp) {
                                       document.getElementById('loading').style.display = 'none';
                                   });
    });
    </script>
</apex:page>
9
  • That is the right way to get a query string parameter from a URL in Visualforce, but I'm not sure about the other details in your situation. Can you share how you're relaying this ID to your lightning component (Aura or LWC?) and can you verify that you are capturing the ID within your Visualforce page?
    – nbrown
    Commented Jul 19, 2021 at 12:48
  • @nbrown, I have edited my post. I am trying to pass the parameter from vf page to component. I checked it returned null.
    – User2805
    Commented Jul 19, 2021 at 12:59
  • and to be clear, have you confirmed it's null in the VF page (ex. var filterId) or in the LWC? Commented Jul 19, 2021 at 13:27
  • Yes, I have checked it returned null...
    – User2805
    Commented Jul 19, 2021 at 13:28
  • The CurrentPage won't have the URL you see when you're on the list view as it opens a new page (which it'll be this URL). If you do "{$CurrentPage.URL}" you'll see the URL you're accessing and why it's not pulling it in. Do you have Display Checkboxes (for Multi-Record Selection) selected for this button? Commented Jul 19, 2021 at 13:48

2 Answers 2

0

I have found the solution for the above issue.

var vfRetURLInSFX = '{!JSENCODE($CurrentPage.parameters.vfRetURLInSFX)}';

Using above code snippet we can fetch the page URL from Lightning List View Button...

0

after Summer'24 release, vfRetURLINSFX returns List view Developer name instead List view ID in the url

New contributor
abhi om is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2

You must log in to answer this question.

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