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
Aditya Mishra 14Aditya Mishra 14 

Opening a modal with force:recordEdit throws “Invalid Record Id or Record not accessible,” but then it works, Is there any way we can hide that initial Error Message

Hi,
In the lighting Component I am trying to open an Edit Modal with Save and Cancel Buttons. Works perfectly Functionally However initially 
Opening a modal with force:recordEdit throws “Invalid Record Id or Record not accessible,” but then it works, Is there any way we can hide that initial Error Message
NagendraNagendra (Salesforce Developers) 
Hi Aditya,

Sorry for this issue you are facing.

Here's the code, which works great for the above issue.

Component:
<aura:attribute name="editActive" type="boolean" default="false"/>


<!-- Edit Payment Modal -->
<aura:if isTrue="{!v.editActive}">
    <div class="slds-container_fluid">
        <section>
            <div aria-hidden="false" id="editPanel" role="dialog" class="slds-modal slds-fade-in-open slds-backdrop slds-backdrop_open" style="display:block;">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close">
                            <span class="slds-assistive-text">Close</span>
                        </button>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Edit Payment</h2>
                    </header>
                    <div class="slds-modal__content slds-p-around_medium">
                        <force:recordEdit recordId="{!v.paymentId}" aura:id='edit'/>
                    </div>
                    <footer class="slds-modal__footer">
                        <button class="slds-button slds-button_neutral" onclick="{!c.save}">Save</button> 
                        <button class="slds-button slds-button_neutral" onclick="{!c.cancel}">Cancel</button>     
                    </footer>  
                </div>
            </div>
        </section>
    </div>
</aura:if>
<!-- End Edit Payment Modal -->

Controller:
cancel: function(cmp, event, helper)
    {
        cmp.set("v.editActive", false);
    },

    save : function(cmp, event, helper){
        cmp.find("edit").get("e.recordSave").fire();
        cmp.set("v.editActive", false);
        helper.refreshView(cmp, event, helper);
    },
Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
Aditya Mishra 14Aditya Mishra 14
Thanks Nagendra, the only problem here is When "{!v.editActive}" is going to be Set as True. So it will never enter the Modal Section. Since it is set as False and never set to True. I tried this and it now modal is not getting launched.