+ Start a Discussion
Krishna KatveKrishna Katve 

Error while saving a record using lightning data service

I am getting below error while saving record using force:recorddata saveRecord methd.

{"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":{}}

Interesting thing about this is record is getting created in salesforce but respose is coming as error. Please check below save record call
 
component.find("apiRequestCreator").saveRecord(function(saveResult) {
                console.log("-----Save Result--"+JSON.stringify(saveResult));
                if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                    // record is saved successfully
                    component.set("v.message","API Request submitted successfully. Download API key from Display APi Request tab.");
                    helper.uploadFiles(component, saveResult.recordId);
                } else {
                    component.set("v.message"," Error occurred while submitting request, Please contact varian helpdesk.");
                    component.set("v.hasErrors", true);
                    console.log('Unknown problem, state: ' + saveResult.state +
                                ', error: ' + JSON.stringify(saveResult.error[0])+'---'+saveResult.error[0].pageErrors[0].statusCode);
                    if(saveResult.error[0].pageErrors[0].statusCode == "DUPLICATE_VALUE"){
                        var apiTypeKey =  component.get("v.customerDetails.Software_System__c")+", "+component.get("v.customerDetails.API_Type__c");
                        if(!$A.util.isEmpty(component.get("v.customerDetails.X3rd_party_Software__c"))){
                            apiTypeKey = apiTypeKey + ", "+ component.get("v.customerDetails.X3rd_party_Software__c");
                        }                            
                        component.set("v.message","You have already submitted request for "+apiTypeKey);
                    }else{
                        component.set("v.message"," Error occurred while submitting request, Please contact varian helpdesk.");
                    }
                }
            });



Please advise.

Thanks
Best Answer chosen by Krishna Katve
Krishna KatveKrishna Katve
Salesforce does not support lightning data service in communities and this force:recordata was getting used in communities. I had to write apex to save record.
Check this link for more information : https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service_considerations.htm