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

<attribute type=MyCustom_Object__c /> in Lightning Out is not working

We are using a Lightning Out and have a simple Input Box with a Button. The button when clicked, retrieves the value of the input box and inserts it in the MyCustom_Object__c.

When the lightning attribute type is of "MyCustom_Object__c" then the Lightning Out does not work, however, if we use the type "Object" it works. Any ideas?
<aura:attribute name="MyRecord" type="MyCustom_Object__c" access="GLOBAL"/>
<aura:attribute name="MyRecord" type="Object" access="GLOBAL"/>

<aura:component access="GLOBAL" controller="tempLightningOut" 
        <aura:attribute name="MyRecord" type="MyCustom_Object__c" access="GLOBAL"/>
        <p> Lightning Out Testing </p>
        <lightning:input aura:id="inputNameField" label="Name" name="inputNameField" />
        <lightning:button variant="brand" label="Submit" onclick="{! c.handleClick }" />

<aura:application extends="ltng:outApp"  implements="ltng:allowGuestAccess" access="GLOBAL" >
            <aura:dependency resource="markup://c:tempComponent" type="COMPONENT"/>

handleClick : function(component, event, helper) {
        var cmp = component.find('inputNameField');

        var inputValue= cmp.get("v.value");

            var cmp = component.find('inputNameField');
            inputValue: inputValue

        callServer : function(component,method,callback,params) {
            var action = component.get(method);
            if (params) {
            action.setCallback(this,function(response) {
                var state = response.getState();
                if (state === "SUCCESS") { 
                    // pass returned value to callback function
                } else if (state === "ERROR") {
                    // generic error handler
                    var errors = response.getError();
                    if (errors) {
                        console.log("Errors", errors);
                        if (errors[0] && errors[0].message) {
                            throw new Error("Error" + errors[0].message);
                    } else {
                        throw new Error("Unknown Error");

**tempLightningOut Apex Controller**
public class tempLightningOut {
            public static void insertRecord(String inputValue) {
                MyCustom_Object__c rec = new MyCustom_Object__c();
       = inputValue;
                insert rec ;

<!DOCTYPE html>

<script src="" type="text/javascript"> </script>

<script type="text/javascript">

    $Lightning.use("c:tempApp",    // name of the Lightning app
        function() {                  // Callback once framework and app loaded
                "c:tempComponent", // top-level component of your app
                { },                  // attributes to set on the component when created
                "lightningLocator",   // the DOM location to insert the component
                function(cmp) {
                    // callback when component is created and active on the page

        ''  // Community endpoint


<body >

		<div id="lightningLocator" style="height:100%;width:100%;"></div>

NagendraNagendra (Salesforce Developers) 

I am not sure this would help, but I can suggest using 2 best practice fixes:
  1. In your Visualforce do not include script <script src="" type="text/javascript"> </script>, Instead use <apex:includeLightning />
  2. In your app remove the markup: <aura:dependency resource="c:tempComponent" type="COMPONENT"/>
Hope this helps.

Thanks for trying out to help,but:

1) This is actually NOT a visualforce page. We're using a web container like a Heroku to display Lightning Out. 
2) Removing it didn't make any difference. I think it is actually required to have it in there.

I did made progress though. It has something to do with namespaces, even if our org is not using namespaces we still need to specify "c.MyCustom_Object__c" if we are to leverage the component in lightning out. I'm still having issues getting the lightning controller to recognize the Apex Method though.

<aura:attribute name="MyRecord" type="c.MyCustom_Object__c" access="GLOBAL"/>