0

I need to pre populate few fields like Ordered Date when user clicks on "Save & New" button while trying to create a record in lightning.

Lets say when user clicks New button on the custom object list page, user is shown with fields; user fill those fields with valid values and clicks "Save & New" button which will save and open another pop up where few fields need to be pre populated with the values which were entered in the first creation of record.

Thanks in advance.

0

Salesforce has added a new feature in lightning that you can show prepopulated field from custom buttons you can follow this syntax to populate values

/lightning/o/Account/new?defaultFieldValues=
    Name={!URLENCODE(Account.Name)},
    OwnerId={!Account.OwnerId},
    AccountNumber={!Account.AccountNumber},
    NumberOfEmployees=35000,
    CustomCheckbox__c={!IF(Account.SomeCheckbox__c, true, false)}

Whilst you want to pre-populate values then you can create a custom lightning component using lightning: RecordEditForm and set predefined values in record edit form and on you can add your custom button there save and new and true same component to reinitialised values refer this link for Lightning:RecordEditForm

| improve this answer | |
  • Thank you Dheeraj. Let me try this and let you know whether I am able to achieve it or not. – getty May 6 at 9:53
  • its very simple you will get sample code in google as well. if you stuck anywhere feel free to ask. – Dheeraj Pandey May 6 at 11:27

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.