Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lightning-record-edit-form onLoad function firing incorrectly #4863

Open
letti2017 opened this issue Nov 14, 2024 · 4 comments
Open

Lightning-record-edit-form onLoad function firing incorrectly #4863

letti2017 opened this issue Nov 14, 2024 · 4 comments
Labels
External: Lightning Components Categorizes issue or PR as related to Lightning base components.

Comments

@letti2017
Copy link

Description

Steps to Reproduce

  • Create a lightning-record-edit-form with a recordId, recordTypeId, and object-api-name filled out with an existing record
  • Use lightning-input-field with any fields on the specific object
  • Use the onLoad function provided for lightning-record-edit-form, then access the event.detail.record object that is returned, which should consistently have the list of fields (i.e. event.detail.record.fields) for the record specified in the lightning-record-edit-form
  • The event.detail.record.fields should consistently have the most up-to-date information on the fields provided in lightning-record-edit-form and should only fire once
<template>
	<lightning-record-edit-form
		object-api-name={objectApiName}
		record-id={recordId}
		record-type-id={recordTypeId}
		onload={onLoad}
	>
		<lightning-input-field
			field-name={fieldName}
			data-full-path-name={fieldDatabasePath}
		></lightning-input-field>
	</lightning-record-edit-form>
</template>
onLoad(event) {
	const record = event.detail.record;
	console.log(record.fields);
}

Expected Results

onLoad function in the above example only fires once and contains the most up-to-date information on the record provided in the html.

Actual Results

onLoad is fired inconsistently and may not contain the most up-to-date information, which can cause issues when using the event.detail.record to run specific rendering rules based on the values provided for the record.

Browsers Affected

All Browsers, all versions.

Version

  • LWC: v8.8.0
@wjhsf wjhsf added the External: Lightning Components Categorizes issue or PR as related to Lightning base components. label Nov 14, 2024
@wjhsf
Copy link
Contributor

wjhsf commented Nov 14, 2024

This is an issue with a Lightning Component, not the LWC framework (this repo). To resolve your issue, I would recommend opening a Salesforce Stack Exchange question or a Salesforce case.

@letti2017
Copy link
Author

I will raise a case as well, just wanted to get as many eyes on this as possible since it's causing our team a lot of problems with rendering based on the event.detail.record object that comes back from onLoad

@Templarian
Copy link
Contributor

Updating records outside of standard LDS wires might be picking up cached values. LDS Consideration Docs

https://developer.salesforce.com/docs/component-library/bundle/lightning-record-edit-form/documentation
The "load" section goes into detail what causes the onload to trigger. Posting on Stack Exchange might be able to offer additional support how to get latest data.

@letti2017
Copy link
Author

Updating records outside of standard LDS wires might be picking up cached values. LDS Consideration Docs

https://developer.salesforce.com/docs/component-library/bundle/lightning-record-edit-form/documentation The "load" section goes into detail what causes the onload to trigger. Posting on Stack Exchange might be able to offer additional support how to get latest data.

I must be missing something then, because based on my understanding of the documentation provided here, the onLoad function will fire when LDS has updates to the record from the system.
However, I've noticed that without changing any of the values on the record, either on the server or within the lwc itself, the event.detail.record still does not contain the most up-to-date information somewhat randomly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External: Lightning Components Categorizes issue or PR as related to Lightning base components.
Projects
None yet
Development

No branches or pull requests

3 participants