Salesforce Asked by user1883984 on November 28, 2021
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>
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.
Answered by Ysr Shk on November 28, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP