2

To be more specific, I have the following scenario that just happened:

I developed a component on a sandbox (development environment). This component uses force:recordData to retrieve some field data (oh really?) that is going to be used to conditionally render other fields and informations on the component.

After testing it on the sandbox, I proceeded to deploy it to the QA environment, where I thought all the fields were at least visible to the user. I forgot to give access to a single field that was used on the force:recordData query and the component data stopped loading.

It took me some hours, but I figured out that when a field is used on the recordData component and the user doesn't have access to it, then the whole query fails. Is this the intended behaviour? Why? And more importantly: how can I prevent the data retrieval from failing due to a single field not being accessible?

I have the following code on it:

<aura:component description="MyLittleComponentCantBeThisBuggy" implements="force:hasRecordId,flexipage:availableForRecordHome">
    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="caseRecord" type="Case"/>

    <aura:attribute name="fields" type="String[]" default="[
        'Id',
        'AccountId',
        'CustomField__c',
        'AnotherField__c'
    ]"/>

    <force:recordData
            recordId="{!v.recordId}"
            fields="{!v.fields}"
            targetFields="{!v.caseRecord}"
            mode="EDIT"
            aura:id="recordDataService"
    />

    <div class="slds-box">
        ...
    </div>
</aura:component>
2

There is not much you can do here. The data services are designed such a way that you need to make sure the running user using the lightning component has access to the fields. The only alternative, if you want to avoid this behavior, is to go Apex class without sharing.

Your Answer

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

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