You need to sign in to do that
Don't have an account?
sheila srivatsav
load record using LDS
I am tring to get the basic right for working on force:recorddata
I want to load the record when I click any opportunity record in lightning but no record values are showing up.
I created a new action and added the button to the page layout of opportunity object.
Now when I click any opportuntity record then I just a poup appears but I don't see any values of the selected record.
please correct me if I am doing wrong.
thanks
sheila
I want to load the record when I click any opportunity record in lightning but no record values are showing up.
<aura:component implements="flexipage:availableForAllPageTypes, force:lightningQuickAction, force:hasRecordId" access="global"> <!--define the object ion which u want to perform the operations--> <aura:attribute name="oppor" type="Opportunity"/> <aura:attribute name="recordId" type="String"/> <aura:attribute name="recordError" type="String" description="An error message bound to force:recordData"/> <aura:attribute name="opporRecord" type="Opportunity" description="A simplified view record object to be displayed"/> <force:recordData aura:id="forceRecordCmp" recordId="{!v.recordId}" targetRecord="{!v.oppor}" targetFields="{!v.opporRecord}" targetError="{!v.recordError}" recordUpdated="{!c.handleRecordUpdated}" fields="ID,Name,StageName,Amount"/> <div class="slds-box"> <div class="slds-text-heading_medium"> Load Opportunity - Data Service </div> <div class="slds-form--stacked slds-tile"> <div class="slds-form-element"> <label class="slds-form-element__label" >Name: </label> <div class="slds-form-element__control"> <ui:outputText class="slds-input" value="{!v.opporRecord.Name}" /> </div> </div> <div class="slds-form-element"> <label class="slds-form-element__label" >Stage name : </label> <div class="slds-form-element__control"> <ui:outputTextArea class="slds-input" value="{!v.opporRecord.StageName}" /> </div> </div> <div class="slds-form-element"> <label class="slds-form-element__label" >Amount : </label> <div class="slds-form-element__control"> <ui:outputTextArea class="slds-input" value="{!v.opporRecord.Amount}" /> </div> </div> </div> </div> </aura:component>
I created a new action and added the button to the page layout of opportunity object.
Now when I click any opportuntity record then I just a poup appears but I don't see any values of the selected record.
please correct me if I am doing wrong.
thanks
sheila
Try this code. It is displaying and saving records correctly.
Component:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Component:
Screenshots:
Also, please refer to the below links which might help you further.
https://www.jitendrazaa.com/blog/salesforce/lightning-data-services-standard-controller-for-lightning-components/
http://sfdcmonkey.com/2017/07/31/lightning-data-service/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I got the result from ur code.
My query is why do we have to create a record page and then use available:forrecordHome interface.
Can we make it work without this?
You need to create a record page to display related records. And the component must implement flexipage:availableForRecordHome or flexipage:availableForAllPageTypes for it to be available in the App Builder when editing a record homepage. If the component should only be available for record home pages then it should implement the more restrictive flexipage:availableForRecordHome which will indicate that the system should enforce that the component is only available in the App Builder component panel when editing a record homepage.
I hope it helps you.
Kindly mark this as solved if the information was helpful.
Regards,
Khan Anas
I am doing the save functionality also
can u pls go through code?
for selected opportunity reord, its not displaying values and not saving
Try this code. It is displaying and saving records correctly.
Component:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas