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
Nithin SinkaranNithin Sinkaran 

Access Current page Header, URL and Query string from Apex

Deal All,

Is there a way we can access current page URL, its query string and current request heards from Apex? I am looking to use it across LWC and screen flows to gather these information for furthe validations.

Thanks 
ankit bansalankit bansal
Hi Nithin,
suppose your URL is https://www.website.com?queryparam1=param1&queryparam2=param2
You can use the following code in LWC to get the values of the queryparam1 and then pass it to your apex method for further processing-
import { CurrentPageReference } from 'lightning/navigation';
import { LightningElement,track,api,wire } from 'lwc';

export class LWCNAME {
@wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
       if (currentPageReference) {
          let urlStateParameters = currentPageReference.state;
          if(urlStateParameters){
                this.variable1 = urlStateParameters.queryparam1;
            }
       }
    }
}