You need to sign in to do that
Don't have an account?
Jeffrey Tanzman 26
Single field lightning component
Hi. I'm an Admin and not a Developer, first off. I want to create a simple Lightning Component with one field (custom) on a standard object so that it may be displayed on the right side of a Lightning Record Page, separate from other fields on the same record. In essence, all fields except the single field, will be in the main standard Record Detail component and the single field will be in its own component on the right. How would I go about creating a Lightning Component with just one field?
I trust you are doing splendidly and enjoying the season.
Below is the sample code which I have tested in my org and it is working fine.
Component:
A lightning:recordForm component enables you to quickly create forms to add, view, or update a record. Using this component to create record forms is easier than building forms manually with lightning:recordEditForm and lightning:recordViewForm.
The objectApiName attribute is always required, and the recordId is required unless you’re creating a record.
Note: Add this component to Lightning app builder.
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
Thank you for the quick reply! Slight correction: the object is custom however it shouldn't matter I don't think BUT I get a "Object <object name> is not supported in one app" message when I drag the custom component onto the Lightning Record Page. I double-checked the API Name is correct. I haven't Saved it yet. Thoughts, or should I Save it and see if it works?
You can use this component on custom object also. Make sure you implements "flexipage:availableForRecordHome,force:hasRecordId". Also, check the objectApiName in lightning:recordForm tag. Then, add it to Lightning app builder page, save it and activate it.
Screenshot:
Regards,
Khan Anas
Thanks again for your reply! The field I'm 'isolating' from the others is a Rich Text type and the "div" and "class" values don't seem to work, and the value - or image(s) in this case - isn't displayed in the new component (it does display when the field is included in the standard Record Detail component). I'm seeing the section title and an empty box below it. Any further thoughts? Again, I'm not a developer and don't have a complete understanding of the "div" and 'class" settings within SLDS convention.
Imagine you want a new component on the lightning page for your case records (Or any other object), where only a single (Or selected set of fields) are being shown under certain criteria (E.g. if a checkbox is checked).
What I would do is:
1- From the object manager, select the object and create a new "Action" from Buttons,Links & Actions (Type: Update a Record), and remember the name you chose for the action,
2- Edit the Layout for the Action and add the field(s) you want,
3- Go to the Lightnig Page you want to edit by opening a record to change, go to Edit Page and add a Related Record component to the Lightning page, wherever you want,
4- Give a Header Label,
5- For the lookup field, select "Use this Case (object name)"
6- Select the action you created for the "Update Action",
7- Set the Conditional Visibility
And you are done.
NimaTahvili3 (Nima) Excellent tip. Your approach worked nicely.