First you create a lightning Application name myFirstApp which retrieve data from the url.
if your URl is like this /c/ChooseCampaignApp.app?AccountId=001P000000eM5z7&ContactId=003P000000hlONG
Then the attribute name must be same as the the Url which contains the values
myFirstApp.app
<aura:application>
<aura:attribute name=”AccountId” type=”String”/>
Value in AccountId Attribute: {!v.AccountId}
<c:AccountByID accGetID=”{!v.AccountId}”/>
Create a component Name: AccountFormByID, adding a server-side controller, AccountFormByIDController, with an attribute: accGetID
<aura:component controller=”AccountFormByIDController” >
<aura:attribute name=”accGetID” type=”String”/>
<aura:attribute name=”ac” type=”Account”/>
<aura:handler name=”init” value=”{!this}” action=”{!c.doInitAction}” />
<ui:inputText label=”Account Name” value=”{!v.ac.Name}”/>
<ui:inputText label=”Type” value=”{!v.ac.Type}”/>
<ui:inputText label=”Industry” value=”{!v.ac.Industry}”/>
</aura:component>
Client-side Controller:
({
doInitAction : function(component, event, helper) {
var action = component.get(“c.find_AccById”);
action.setParams({ “get_accountid”: component.get(“v.accGetID”) });
action.setCallback( this, function(response) {
var state = response.getState();
if (state === “SUCCESS”) {
component.set(“v.ac”, response.getReturnValue());
console.log(response.getReturnValue());
}
});
$A.enqueueAction(action);
},
})
Server side Controller:-
public class AccountFormByIDController {
@AuraEnabled
public static Account find_AccById(Id get_accountid) {
if(get_accountid != null ) {
return [SELECT Id, Name, Type, Industry from Account where ID = :get_accountid];
}
else{
return [SELECT ID, Name, Type, Industry from Account LIMIT 1];
}
}
}