[SalesForce] Connection.js and apex.js are not working in Lightning Component

Connection.js and apex.js are not working in Lightning Component. My code is as follow.

Component Code (RTBasedPicklist):

<aura:component controller="RTBasedPickListController">
    <ltng:require scripts="{!join(',' , '/soap/ajax/40.0/connection.js','/soap/ajax/40.0/apex.js')}" afterScriptsLoaded="{!c.doInit}"/>    
</aura:component>

Controller Code:

({
    doInit : function(component, event, helper) {
        sforce.connection.sessionId='{!GETSESSIONID()}';
        console.log('halo');
        var result = sforce.connection.describeLayout('Opportunity');
        console.log((result));
    }
})

This results as:

Error : This page has an error. You might just need to refresh it.
Action failed: c:RTBasedPicklist$controller$doInit [Failed to execute
'send' on 'XMLHttpRequest': Failed to load
'{baseurl}/services/Soap/u/40.0'.] Failing descriptor:
{c:RTBasedPicklist$controller$doInit}

Best Answer

Connection.js and apex.js are not available in Lightning Components. You'll have to create an Apex Class that returns what you want and call a server side action from your component.

Related Topic