[SalesForce] $A.createComponent with does not work in the community after Spring 19 release

I have the issue but cannot understand what is wrong, hope you will help me here.

There is the community with custom lightning Register component. When you fill some basic info about the user you press Next button that dynamically creates the custom lightning component to fill info about the account.

As I was told, it worked before the Spring 19 release, but the sandbox was updated 3 days ago and it does not work now and $A.createComponent throws an error with Id 1703989902-32917 (1257401656).
However, it does work in the lightning app. The component is being created there.

Here is the code that creates a component:

//a lot of messy code before
var action = component.get("c.validateCustomer");
    action.setParams({email:email});
    action.setCallback(this, function(a) {
        var rtnValue = a.getReturnValue();         
            $A.createComponent(
                "c:StandardFMS_CompanyRegistration",
                 {
                    "Email" : email,
                    "FirstName":component.find("firstname").get("v.value"),
                    "LastName":component.find("lastname").get("v.value"),
                    "Gender":component.find("gender").get("v.value"),
                    "selfLoginUrl":loginUrl
                 },
                 function(newCmp, status, errorMessage) {
                    console.log('Dynamic');
                    if (status === "SUCCESS") {
                       console.log('cmp >>> ' + newCmp);
                    } else if (status === "INCOMPLETE") {
                       console.log("No response from server or client is offline.")              
                    } else if (status === "ERROR") {
                       console.log("Error: " + errorMessage);
                    }
                    var cmp = component.find("unsuccessfulAttempt");
                    cmp.set("v.body", []);
                    cmp.set("v.body", newCmp);
                }
             );                            

        });
        $A.enqueueAction(action);

The method from Apex controller returns null, that is ok.
As I mentioned, it throws an error in the community but works normally in the lightning app.

Here is the short markup of the created component:

<aura:component controller="StandardFMS_CustomerCreationController">
<aura:attribute name="Email" type="String" default="" access="global"/>
<aura:attribute name="FirstName" type="String" default="" access="global"/>
<aura:attribute name="LastName" type="String" default="" access="global"/>
<aura:attribute name="Gender" type="String" default="" access="global"/>
<aura:attribute name="selfLoginUrl" type="String" required="false" default="/"/>
//a lot of messy code after

I tried to add forceCommunity:availableForAllPageTypes and access attribute to the component, but it did not help.
Any help would be appreciated.

Best Answer

After some investigation I found the error.

There is an attribute of type Account in the component that is being created dynamically.

Init handler of that component calls Apex to get info about Account. Since there is no Read permission for Guest user on Account neither no isAccessible() validation for Account in Apex the lightning throws an unknown error with some Id.

As I was told it was working before Spring 19 release, perhaps the release reset Guest profile settings. But I do not know for sure, because there is no VCS for that project. So, the issue is in the code which is poorly performed.

Related Topic