Micro Project :: LWC - LDS - record-form vs record-edit-from & ShowToast vs Blueprint & Navigation

Опубликовано: 22 Февраль 2026
на канале: Salesforce Applied
506
9

MICRO PROJECT :: Kali, the VP of sales at upquotient.com, a career transformer and an amplifier company, based on the inputs form his Sales Agents has entrusted you, the seasoned LEX Developer, to implement the below business requirements.

1] Find a quick way to create and associate a Contact to an Account.
Contact Fields (Account Id, Salutation, First Name & Last Name)
2] Create and link the Contact to an Account from 2 places - App page and Account record page.
3] Upon successful Contact create provide the Agents a toast message
"Success! Contact Created [contactId] - Click Close to Navigate"
4] Let the toast message be shown until the agent click the Close button.
5] Upon clicking the Close button navigate the agent to the Contact record page displaying the Contact just created.

Special request from Kali ::
The Form when displayed should prepopulate the Account Name when the component is placed inside the Account record page.
The Form when displayed should prepopulate the salutation Field to Prof.
The same artifact developed should work seamlessly both on App page and Record Page. Absolutely avoid Apex as low code
solution is preferred.

Solution

As it is customary for you to run a thorough analysis, you relished on the same and decided on the below artifacts ...

1] A Lightning Web Component (use base lightning component) leveraging LDS (Lightning data Service),
First, you decided to implement lightning-record-form base component to allow the agent create a Contact and associate the same with an Account. Will this work, got to see?
Second, you got to experiment with lightning-record-edit-form base component, got to see this working? [actual solution]

2] For the toast message you found 2 ways - first, to leverage "ShowToastEvent" (straight forward) and second, to use the toast blueprint (CSS) [actual solution] to customize the behavior. Need to experiment both to ascertain which fits the bill.

3] Construct a PageReference type with appropriate parameters and use the navigate method to allow the agent to navigate to the Contact record page.

4] Surface the Custom Component inside an App page and Account record page