0

Strange situation. This code works perfectly for me, but does not load for some users. I have searched permissions and security on Aura bundles, but cannot find what I need.

Here is the code. The idea is that the contactDetails component should be able to find the correct information if it is given a contact ID. The oppContact component is what loads the record and give the child component the contact ID.

When a regular user opens the lightning page, the top part of the page is greyed out and has a spinner that doesn't go away. Also, when I run the console debugger, I don't get the contactDetails component is running........................... like I expect.

One thing it might be is the GID field?? That is not editable by everyone. Is that causing some kind of issue?

What do?


contactDetails

<aura:component access="global">
<aura:attribute name="contactID" type="Id" access="global"/>
<aura:attribute name="contactRecord" type="Object"/>
<aura:attribute name="simpleContRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>

<!-- Load Contact -->
<force:recordData aura:id="contactRecordData"
                  recordId="{!v.contactID}"
                  targetRecord="{!v.contactRecord}"
                  targetFields="{!v.simpleContRecord}"
                  targetError="{!v.recordError}"
                  recordUpdated="{!c.contLoaded}"
                  layoutType="FULL"
                  mode="EDIT"/>

<aura:attribute name="loaded" type="Boolean" default="false"/>
<aura:attribute name="editable" type="Boolean" default="false"/>

<!-- Display a lightning card with details about the record -->
<div class="Contact Details">
    <aura:if isTrue="{!v.loaded}">
        <!--show details of the contact -->
        <lightning:card iconName="action:add_contact" title="{!v.simpleContRecord.FirstName + ' ' + v.simpleContRecord.LastName}">
            <aura:if isTrue="{!v.editable}">
                <!-- Edit the record if the edit button is pressed -->
                <div class="slds-p-left_medium">
                    <lightning:recordForm recordId="{!v.contactID}" 
                                          objectApiName="Contact"
                                          layoutType="Compact"
                                          columns="2"
                                          mode="edit">
                    </lightning:recordForm>
                </div>

                <aura:set attribute="else">
                    <!-- Display contact as read only by default -->
                    <lightning:recordViewForm recordId="{!v.contactID}" objectApiName="Contact">
                        <div class="slds-p-horizontal--small">
                            <div class="slds-grid slds-gutters">
                                <!-- First Column -->
                                <div class="slds-col">
                                    <p class="slds-text-heading--small slds-p-top_x-small">                                    
                                        <lightning:outputField fieldName="GID__c" />
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="Primary_Email__c" />
                                        <!--<lightning:formattedEmail label="example email" value="{!v.simpleContRecord.Primary_Email__c}"/>-->
                                    </p>
                                    <p class="slds-text-body--small slds-text-color_weak slds-p-top_x-small">
                                        Phone<br/>
                                        <lightning:clickToDial class="slds-text-body_regular" value="{!v.simpleContRecord.Phone}" recordId="{!v.contactID}"/>
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="Invalid_Phone__c" />
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="SMS_Opt_In__c" />
                                    </p>
                                </div>
                                <!-- Second Column -->
                                <div class="slds-col">
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="Timezone__c" />
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="hed__AlternateEmail__c" />
                                        <!--<lightning:formattedEmail label="example email" value="{!v.simpleContRecord.Primary_Email__c}"/>-->
                                    </p>
                                    <p class="slds-text-body--small slds-text-color_weak slds-p-top_x-small">
                                        Alternate Phone <br/>
                                        <lightning:clickToDial class="slds-text-body_regular" value="{!v.simpleContRecord.Alternate_Phone__c}" recordId="{!v.contactID}"/>
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="DoNotCall" />
                                    </p>
                                    <p class="slds-text-heading--small slds-p-top_x-small">
                                        <lightning:outputField fieldName="Most_Recent_Activity_Date__c" />
                                    </p>
                                </div>
                            </div>
                        </div>      

                        <!-- Button to allow editing -->
                        <br/>
                        <div class="slds-var-p-around_small button-background">
                            <button class="slds-button slds-button_neutral" title="Edit Contact" onclick="{!c.editContact}">Edit Contact</button>
                        </div>
                    </lightning:recordViewForm>
                </aura:set>
            </aura:if>                
        </lightning:card>

        <!-- show spinner if it is loading -->
        <aura:set attribute="else">
            <lightning:spinner alternativeText="Loading the Contact" />
        </aura:set>
    </aura:if>
</div>

<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
    <div class="recordError">
        {!v.recordError}</div>
</aura:if>

contactDetailsController.js

({
contLoaded : function(component, event, helper) {
    var changeType = event.getParams().changeType;
    if (changeType === "ERROR") { 
        /* handle error; do this first! */ 
        console.log('Error loading');
        console.log('Event Paramaters: ' + event.getParams());
    }
    else if (changeType === "LOADED") { 
        console.log('contactDetails component is running...........................');
        console.log('Contact loaded successfully');
        component.set("v.loaded",true);
    }
    else if (changeType === "REMOVED") { /* handle record removal */ }
    else if (changeType === "CHANGED") {
        console.log('Contact was updated');
        component.set("v.editable",false);
        component.set("v.loaded",true);
    }
},

editContact : function(component, event, helper) {
    console.log('Allowing Contact to be edited');
    component.set("v.editable",true);
}

})


Here is the parent, oppContact:

<aura:attribute name="oppRecord" type="Object"/>
<aura:attribute name="simpleOppRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<aura:attribute name="contactID" type="Id"/>

<!-- Load Opp -->
<force:recordData aura:id="oppRecordRD"
                  recordId="{!v.recordId}"
                  targetFields="{!v.simpleOppRecord}"
                  targetError="{!v.recordError}"
                  recordUpdated="{!c.oppLoaded}"
                  layoutType="FULL"
                  mode="VIEW"/>

<aura:attribute name="opploaded" type="Boolean" default="false"/>

<!-- Display a lightning card with details about the record -->
<div class="Contact Component">
        <aura:if isTrue="{!v.opploaded}">
            <!--show Contact component -->
            <c:contactDetails contactID="{!v.contactID}"/>

            <!-- show spinner if it is loading -->
            <aura:set attribute="else">
                <lightning:spinner alternativeText="Loading the Contact" />
            </aura:set>
        </aura:if>
</div>

<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
    <div class="recordError">
        {!v.recordError}</div>
</aura:if>

oppContactController.js

({
oppLoaded : function(component, event, helper) {
    var changeType = event.getParams().changeType;
    if (changeType === "ERROR") { 
        /* handle error; do this first! */ 
        console.log('Error loading');
        console.log('Event Paramaters: ' + event.getParams());
    }
    else if (changeType === "LOADED") {
        console.log('oppContact component is running.......');
        component.set("v.contactID", component.get("v.simpleOppRecord.Contact__c"));
        console.log('oppContact component loaded the opp correctly');
        component.set("v.opploaded",true);
    }
    else if (changeType === "REMOVED") { /* handle record removal */ }
    else if (changeType === "CHANGED") { 
        console.log('Opportunity was updated');
        component.set("v.opploaded",true);
    }
}

})

  • 1
    Can you check the FLS for users who are not able to see the component? – Yaswanth Tikkisetti Feb 11 at 8:38
  • I did that, and the users should have what they need. I will post the solution I found. – Chance 2 days ago
0

I found the answer. It was surprising, but it seems I did not have the direct reference Contact__c on the page layout for that profile. My best guess is that when I used forceRecordData the layoutType="FULL" will only pull the fields from the page layout. Since the Contact__c field was not on there, it was not able to pass that ID on to the child.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.