2

We are using lightning:recordData to create new records from a lightning component. In my dev org I can so something like:

        cmp.find("myRecordCreator").getNewRecord(
        "MyObject__c", // sObject type (objectApiName)
        null,      // recordTypeId
        false,     // skip cache?
        $A.getCallback(function() {
            var rec = cmp.get("v.newRecord");
            var error = cmp.get("v.newRecordError");
            if(error || (rec === null)) {
                helper.showToastErrorMessage("Error initializing record template: " + error);
                return;
            }
        })
    );

When packed and deployed this fails with an error:

You don't have access to this record. Ask your administrator for help or to request access.

I'm pretty sure this is because MyObject__c is a custom object that has a namespace after being deployed.

What is the recommended method of getting the namespace so that I can have a conditional in my code to prepend this object name with a namespace when its running in a managed package? The namespace of this object will be the same namespace of the component itself.

  • 2
    Have you considered developing in DX/scratch orgs to save yourself the hassle of namespace issues? – sfdcfox Sep 13 '18 at 17:35
  • @sfdcfox, yes, but that is not happening right away. – Homerlex Sep 13 '18 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.