1

Currently the following quick action is used to default to a particular record type when entering new records on the system.

I would like to set the "Name" field so that the value defaults to the following string based on the originating account: "Client Meeting: {!v.acct.Name}"

How do I do this?

<aura:component implements="force:hasRecordId,force:lightningQuickActionWithoutHeader"
            controller="AccountQuickEventWithRegCtrl">

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="fields" type="String[]" default="['Name', 'Contact_Name__c', 'Rheolwr_Cleient_Client_Manager__c', 'Project__c', 'Date__c', 'Discussion__c', 'Location__c', 'Update__c', 'Issues_Discussed__c', 'Meeting_Hours__c', 'Twristiaeth__c']"/>
    <aura:attribute name="acct" type="Account" default="{'sobjectType': 
                    'Account'}" />
    <aura:attribute name="recordLoadError" type="String" />
    <lightning:notificationsLibrary aura:id="notifLib"/>

    <force:recordData aura:id="recordLoader" recordId="{!v.recordId}"
                  fields="Name"
                  targetFields="{!v.acct}" targetError="{!v.recordLoadError}" />

    <header class="slds-modal__header" style="width:100%; height:100%">
        <h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">New meeting with {!v.acct.Name}</h2>
    </header>
    <br/>
    <div  style="width:100%; height:100%">
        <lightning:recordForm aura:id="newEvent" fields="{!v.fields}" recordTypeId="0120O000000pF8wQAE" 
                          mode="edit" objectApiName="Event__c" 
                          onsubmit="{!c.submit}" onsuccess="{!c.saved}" oncancel="{!c.cancel}">
        </lightning:recordForm>
    </div>
0

You can use force:recordData events (recordUpdated).

As per the documentation -

The event fired when the record is loaded, updated, or deleted.

And in event handler, you can check if changeType = LOADED, then you can set Name field in that block.

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.