0

I'm an admin trying to work on my first LWC and would appreciate any help on the following requirement -

We have a LWC datatable for the child object (Preferences) and when the user clicks on the New button which will launch the OOTB create page, we would like to pass in the Account ID of parent object (Account) so the relationship can be established. How can this be accomplished? Thanks in advance!

  • Welcome to SFSE. Please, take a Tour and read How do I ask a good question?. The question is purely about solving a business requirement for you and I'd be great if you show any effort (like code snippets) made so far. – Przemysław Tamoń Jan 16 at 12:13
0

If you are placing this child's LWC data table on the parent object's (say Account) record page then you can get the parent record's Id in the "recordId" variable like below:-

import { LightningElement, api } from 'lwc';
export default class TestClass extends LightningElement {
    @api recordId;
}

For more information see here - https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_record_context

After getting the parentId you can pass it to the record's create page by providing the default field values-

For providing default field value refer - https://livingthetrailhead.com/2020/01/12/navigate-to-a-records/

| improve this answer | |

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.