1

We're trying to move to lightning and one of the buttons that has to be converted creates a new case with a new record type and auto populates fields from an old case. I used the Salesforce button converter tool to convert the buttons but it doesn't seem to work properly. The account name and contact name didn't auto populate. I tried to create a custom component to do the same but it still won't auto populate the Account Name and Contact Name. The custom component consists of a Modal that pops up a case custom component. The Account and Contact auto populate in the case custom component but when I try to display that in the Modal it doesn't work properly and show up as a lookup field. The other fields auto populate fine.

Custom Case Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasSObjectName,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="record" type="Case"/>
<aura:attribute name="recordId" type="Id" />
 <lightning:recordEditForm recordId="{!v.recordId}" objectApiName="Case" 
                           onsubmit="{!c.handleSubmit}" 
                           onerror="{!c.handleError}" 
                           onsuccess="{!c.handleSuccess}">
     <lightning:inputField fieldName="Status" />
     <lightning:inputField fieldName="AccountId" />
     <lightning:inputField fieldName="ContactId" />
</lightning:recordEditForm>

`

Modal Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
<!--use boolean attribute for Store true/false value,
make default to "false" so modal box are not display on the load of component. -->
<aura:attribute name="case" type="Case" />
<aura:attribute name="isOpen" type="boolean" default="false"/>

<!--Use "slds-m-around_xx-large" class to add standard X-Large padding to the component--> 
<div class="slds-m-around_xx-large">

    <lightning:button variant="brand"
                      label="Edit Case"
                      title="Edit Case"
                      onclick="{! c.openModel }" />
    <!--Use aura:if tag to display Model Box, on the bese of conditions. [isOpen boolean attribute] -->   
    <aura:if isTrue="{!v.isOpen}">

        <!--###### MODAL BOX Start######--> 
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <!-- ###### MODAL BOX HEADER Start ######-->
                <header class="slds-modal__header">
                    <lightning:buttonIcon iconName="utility:close"
                                          onclick="{! c.closeModel }"
                                          alternativeText="close"
                                          variant="bare-inverse"
                                          class="slds-modal__close"/>
                    <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Edit Case</h2>
                </header>
                <!--###### MODAL BOX BODY Part Start######-->
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                    <c:CustomAccount record="{!v.case.recordId}"/>
                </div>
                <!--###### MODAL BOX FOOTER Part Start ######-->
                <footer class="slds-modal__footer">
                    <lightning:button variant="neutral" 
                                      label="Cancel"
                                      title="Cancel"
                                      onclick="{! c.closeModel }"/>
                    <lightning:button variant="brand" 
                                      label="Like and Close"
                                      title="Like and Close"
                                      onclick="{! c.likenClose }"/>
                </footer>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
        <!--###### MODAL BOX Part END Here ######-->

    </aura:if>
</div>  

0

I removed the custom component and added the code from it to the Modal component and everything is working now.

| improve this answer | |

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.