You need to sign in to do that
Don't have an account?
phaniram satya durga upalapati
force:recordData SaveRecord method is throwing Error but still the record is getting updated.
My sharing settings for Opportunity Object is 'Private'. As part of my lightning component i am using force:recordData to read the record and update few fields i.e. OwnerId to new User and saving the record. Issues is SaveRecord method is updating the record but it is returning error result.
Error: {"state":"ERROR","recordId":null,"error":[{"message":"The requested resource does not exist\n","pageErrors":[{"statusCode":"NOT_FOUND","message":"The requested resource does not exist"}],"fieldErrors":{},"potentialDuplicates":[]}],"entityApiName":null,"action":{}}. Kindly suggest me what might be the issue.
Component(.cmp):
---------------------------
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:attribute name="recordId" type="string" />
<aura:attribute name="record" type="Opportunity" />
<!--Loading the Data from the Opportunity record -->
<force:recordData aura:id="editRecord"
recordId="{!v.recordId}"
fields="['Name','RecordTypeId','OwnerId','Type']"
mode="EDIT"
targetFields="{!v.record}"
recordUpdated="{!c.dataLoaded}"
/>
</aura:component>
controller.Js:
---------------
({
dataLoaded : function(component, event, helper) {
// helper.fetchRec(component);
let rec = component.get("v.record");
rec.Type = '********';
rec.OwnerId = '***************';
component.set("v.record",rec);
},
})
helper.js:
-------------
({
updateRec : function(component) {
component.find("editRecord").saveRecord($A.getCallback((result) => {
if (result.state == "SUCCESS" || result.state === "DRAFT") {
alert('success');
}else{
alert("Error: " + JSON.stringify(result));
}
}
));
},
})
Error: {"state":"ERROR","recordId":null,"error":[{"message":"The requested resource does not exist\n","pageErrors":[{"statusCode":"NOT_FOUND","message":"The requested resource does not exist"}],"fieldErrors":{},"potentialDuplicates":[]}],"entityApiName":null,"action":{}}. Kindly suggest me what might be the issue.
Component(.cmp):
---------------------------
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
<aura:attribute name="recordId" type="string" />
<aura:attribute name="record" type="Opportunity" />
<!--Loading the Data from the Opportunity record -->
<force:recordData aura:id="editRecord"
recordId="{!v.recordId}"
fields="['Name','RecordTypeId','OwnerId','Type']"
mode="EDIT"
targetFields="{!v.record}"
recordUpdated="{!c.dataLoaded}"
/>
</aura:component>
controller.Js:
---------------
({
dataLoaded : function(component, event, helper) {
// helper.fetchRec(component);
let rec = component.get("v.record");
rec.Type = '********';
rec.OwnerId = '***************';
component.set("v.record",rec);
},
})
helper.js:
-------------
({
updateRec : function(component) {
component.find("editRecord").saveRecord($A.getCallback((result) => {
if (result.state == "SUCCESS" || result.state === "DRAFT") {
alert('success');
}else{
alert("Error: " + JSON.stringify(result));
}
}
));
},
})
The solution did not help me as the State of SaveResult is always ERROR and i am seeing the same error message as mentioned in my Question.