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
reettik mitrareettik mitra 

Site scripting in Salesforce

When running this code in developer console then I am getting the output that is the full page code but when I am using the apex code in Lightning Web Component then I a getting the exact value that I want. Note:- LexSessionController provides the session Id When using LWC.

User-added image
 The Output I am getting Using the Lightning Web Component.
User-added imageThe Output I am getting Using the Developer Console(Which is correct and required).
String sfdcURL = URL.getSalesforceBaseUrl().toExternalForm();
String sessionId =  LexSessionController.fetchUserSessionId();
String sessionIdTrim=sessionId.substring(0,15); 
sfdcURL=sfdcURL+'/setup/org/orgstorageusage.jspid=&setupid='+sessionIdTrim+'CompanyResourceDisk&retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DDataManagement';
String html = new PageReference(sfdcURL).getContent().toString();

 
SwethaSwetha (Salesforce Developers) 
HI Reettik,

I tried below instead inplace of LEXController you stated
UserInfo.getSessionId().SubString(0,15);
It appears to be an issue with the sfdcURL

Please consider correcting from 

sfdcURL=sfdcURL+'/setup/org/orgstorageusage.jspid=&setupid='+sessionIdTrim+'CompanyResourceDisk&retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DDataManagement';

sfdcURL=sfdcURL+'/setup/org/orgstorageusage.jsp?id='+sessionIdTrim+'&setupid=CompanyResourceDisk&retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DDataManagement';

Despite making this correction, if it still doesn't work ,you might want to try https://www.sfdcpoint.com/salesforce/navigation-service-in-lwc/

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you