You need to sign in to do that
Don't have an account?
Sam Arora
how to get sobject and Id in lightning components controller
<aura:component implements="force:hasRecordId,force:hasSObjectName" access= "global" >
<ltng:require styles="/resource/SLDS231/assets/styles/salesforce-lightning-design-system-ltng.css"/>
<aura:attribute name="recordId" type="String" default="{!recordId}"/>
<aura:attribute name="sObjectName" type="String" default="{!sObjectName}"/>
<aura:handler name="init" value="{!this}" action="{!c.gotoURL}"/>
<h1>
Hello Geeky developers :)
<br/>
I am from lightning.
</h1>
<br/>
<!-- recordId and sObjectName attributes will be available for use.-->
<h2> This is the record id : {!v.recordId}</h2>
<br/>
<h2> This is the SObject name of the current record : {!V.sObjectName }</h2>
</aura:component>
({
gotoURL : function(component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
var PG_ID = component.get("v.recordId");
var PG_SOBJ = component.get("v.sObjectName");
action.setParams({
"P_ID": PG_ID
});
action.setParams({
"P_sob": PG_SOBJ
});
}
})
<ltng:require styles="/resource/SLDS231/assets/styles/salesforce-lightning-design-system-ltng.css"/>
<aura:attribute name="recordId" type="String" default="{!recordId}"/>
<aura:attribute name="sObjectName" type="String" default="{!sObjectName}"/>
<aura:handler name="init" value="{!this}" action="{!c.gotoURL}"/>
<h1>
Hello Geeky developers :)
<br/>
I am from lightning.
</h1>
<br/>
<!-- recordId and sObjectName attributes will be available for use.-->
<h2> This is the record id : {!v.recordId}</h2>
<br/>
<h2> This is the SObject name of the current record : {!V.sObjectName }</h2>
</aura:component>
({
gotoURL : function(component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
var PG_ID = component.get("v.recordId");
var PG_SOBJ = component.get("v.sObjectName");
action.setParams({
"P_ID": PG_ID
});
action.setParams({
"P_sob": PG_SOBJ
});
}
})
You must have a component which implements force:hasRecordId.
<aura:attribute name="recordId" type="String" />
You must use $A.get("e.force:navigateToSObject")
Also one point to note,you must view the component in Salesforce 1 view in browser by clicking inspect element or view it directly in mobile salesforce 1 to get the expected result.
Else $A.get("e.force:navigateToSObject") would return null.
Let me know if you need further help.
Thanks and Regards,
Shiva RV