I'm trying to solve a problem with old data being saved. This component is on a detail page:
- Open record
- Amend one field and save
- Use component to trigger a different field to update using
force:recordData
- Refresh the page
- See that your first change is reverted
Am I doing this right to refresh the data? Here is my code:
<force:recordData aura:id="fieldUpdate"
layoutType="FULL"
recordId="{!v.recordId}"
targetFields="{!v.objectFields}"
targetError="{!v.errorMessage}"
mode="EDIT"/>
In the controller I am doing:
component.find("fieldUpdate").reloadRecord(true);
component.set("v.objectFields." + myFieldName, myFieldValue);
component.find("fieldUpdate").saveRecord($A.getCallback(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
console.log("Success!");
} else if (saveResult.state === "INCOMPLETE") {
thisRef.showErrorMessage("User is offline, device doesn't support drafts.");
} else if (saveResult.state === "ERROR") {
thisRef.showErrorMessage("There was a problem updating the Salesforce record: " + saveResult.error[0].message);
} else {
thisRef.showErrorMessage("Unknown problem, state: " + saveResult.state + ', error: ' + saveResult.error[0].message);
}
}));
So when I call reloadRecord
it doesn't actually get the change I just made in the UI. Am I doing something wrong?