I have a Lightning Component controller doing the following:
- inserting a custom object
Audit__c
record via LightningDataService. - on successful insert calls a server-side controller method, passing one String parameter,
auditId
.
The Server-Side controller then queries the database for an Audit__c
record WHERE Id=: auditId
. This query is returning 0 rows. I've validated that the string being passed to filter the query is indeed the correct Id
of the newly created Audit__c
record.
Why isn't the SOQL query picking up the new Audit__
c record even when being fed the right Id
(as String
). Is there some sort of casting issue that is causing Apex not to match the String
filter value to a record Id
?
Client-Side Controller (1 & 2)
component.find("auditCreator").saveRecord(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
// record is saved successfully
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title": "Saved",
"message": "The audit was successfully initiated."
});
resultsToast.fire();
var action = component.get("c.createAuditObjects");
action.setParams({ auditId : JSON.stringify(saveResult.recordId)});
Server-Side Controller
public class initAuditReview {
@AuraEnabled
public static void createAuditObjects(String auditId){
// auditId present
System.debug('auditId is '+auditId);
Audit__c parentAudit = [SELECT Id, Name FROM Audit__c WHERE Id=: auditId];
Debug Log
1.
instead of1)
to get<ol>
formatting. See also: Markdown Editing Help.