Summary
The issue at hand is the inability to update an EntityReference of a record in a PCF grid component. The setValue and save functions work fine for simple data types, but updating a lookup column results in an Uncaught UciError: Invalid snapshot with id undefined. This error typically occurs when the incorrect column name parameter is used with setValue, but in this case, the column name is correct.
Root Cause
The root cause of this issue is likely due to the following reasons:
- Incorrect formatting of the EntityReference object
- Missing or incorrect id property in the EntityReference object
- Inconsistent entityType name (etn) in the EntityReference object
Why This Happens in Real Systems
This issue can occur in real systems due to:
- Misunderstanding of the EntityReference object structure
- Incorrect documentation or examples
- Lack of validation for the EntityReference object
Real-World Impact
The real-world impact of this issue includes:
- Inability to update lookup columns in PCF grid components
- Errors and exceptions when trying to save changes
- Frustration and delays in development and deployment of PCF components
Example or Code
public updateView(context: ComponentFramework.Context): React.ReactElement {
const recordIds = context.parameters.items.sortedRecordIds
const record = context.parameters.items.records[recordIds[0]]
const entityReference = {
id: {
guid: "********-****-****-****-************"
},
etn: "systemuser",
name: "Jon Doe"
}
record.setValue("pre_resource", entityReference)
record.save()
}
How Senior Engineers Fix It
Senior engineers can fix this issue by:
- Verifying the correct formatting of the EntityReference object
- Ensuring the id property is correctly set in the EntityReference object
- Using the correct entityType name (etn) in the EntityReference object
- Validating the EntityReference object before setting and saving the value
Why Juniors Miss It
Junior engineers may miss this issue due to:
- Lack of experience with EntityReference objects
- Insufficient understanding of PCF grid component documentation
- Inadequate testing and validation of code
- Overlooking the importance of correct entityType name (etn) in the EntityReference object