Lightning App – getting URL parameter

We are planning to convert some of our VF pages to Lightning apps. Some our VF pages, particularly surveys are URL parameter-driven, since we send survey links directly to users, i.e. https://[vf_instance]

Say we convert the VF page to an Lightning app, we would probably be sending the Lightning survey like this https://[vf_instance]


In VF page controller, PageReference.getParameters() contains the much needed caseid

However, in Lightning component controller, PageReference.getParameters() does not contain any URL parameters.

How can I get the URL parameter in Lightning app/component apex controller?



In lightning whatever attribute you define can be passed as a query parameter .

Lets take a look with sample example

  <aura:attribute name="whom" type="String" default="world"/>
   Hello {!v.whom}!

Here is how the result will look like

enter image description here

Now I will add a query parameter with value as per my attribute defined whom in the URL and now the result will be as below

enter image description here

In very simple terms you just need to define an aura:attribute and you are good

 <aura:attribute name="caseid" type="String"/>

Source : Link , Question Author : pnoytechie , Answer Author : Mohith Shrivastava

Leave a Comment