function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Smita HodiggeriSmita Hodiggeri 

How to display a list of records to to print using aura component -- How to construct the URL to fetch all the records to print

Hi Community,

I have inherited an aura component that basically prints a list of records dispalyed right down below for the community users to print.
This was written back in 2017 and no body has seen it working.
I played around a bit and observed that The URL for salesforce community being used under Lightning experience Transition Assistant--> Feature Settings--> All Sites is changed to following
New URL
https://community.ausure.com.au
The URL being used in Controller.Js is 
"url": "http://ausureib.force.com/AusureCommunity/MyCPDPointsRegister?recordId="+recordId

I am not sure how to construct a correct URL so that it prints all the records of CPD Register Points for a community user properly on clicking the button. 

My Controller Code.
({
    openCPDPointsList : function(component, event) {
    var urlEvent = $A.get("e.force:navigateToURL");
    var recordId = component.get("v.recordId");    
        urlEvent.setParams({
            url:"http://ausureib.force.com/AusureCommunity/MyCPDPointsRegister?recordId="+recordId           
        });
    urlEvent.fire();
    },
})

Tried constructing URL Like
 url": "https://community.ausure.com.au/s/my-cpd-register?recordId="+recordId
But this brings me back to the same page instead of taking me to printable view.

User-added image
Shri RajShri Raj
To construct the correct URL to fetch all the records to print, you can try the following steps:
Go to the detail page of the record you want to print.
Right-click anywhere on the page and select "View page source".
Search for the URL of the page that displays the records. It should be something like https://<yourSalesforceInstance>.lightning.force.com/<recordId>.
Replace the <recordId> with {!recordId}, where recordId is a merge field that will be replaced by the actual record Id when the URL is called.
Save this URL in your component's JavaScript code as the URL for the navigation event.
({
    openCPDPointsList : function(component, event) {
        var urlEvent = $A.get("e.force:navigateToURL");
        var recordId = component.get("v.recordId");
        var url = "https://<yourSalesforceInstance>.lightning.force.com/<recordId>".replace("<recordId>", recordId);
        
        urlEvent.setParams({
            url: url
        });
        urlEvent.fire();
    },
})

 
Smita HodiggeriSmita Hodiggeri
Hi Shri,

Thank you for taking time to analyse the problem and providing a resolution.
This aura component button is on community. 
When I click on the button CPD Points LIst to Print it should print the records displayed right down below the button which can be seen in the screenshot. 


User-added image

In order to obtain the recordid to construct the URL I right clicked on the bottom yellow highligted section of list view and I was lost!
Does it sound like I am still on the right path.
Much appreciate your help!
Thanks,
Smita