I am composing an LWC Component, that makes an imperative apex call to a method that takes ALL the fields of a record and return them to the client." I am using dynamic SOQL query, that expects a recordId from user and makes this call.
Apex Class:
public static Broker_Application__c getDraftData(String recordId){
Set<String> SobjectFields = Schema.getGlobalDescribe().get('Broker_Application__c').getDescribe().fields.getMap().keySet();
//Error in next line
Broker_Application__c lstBroker = (Broker_Application__c) Database.query('SELECT ' + String.join(new List<String>(SobjectFields), ',') + ' FROM Broker_Application__c WHERE Id=:recordId LIMIT 1');
return lstBroker;
}
The corresponding JS in apex interacts with this as:
getDraftData({ recordId: this.recordId })
.then((data) => {
console.log('data received');
console.log('draft data received from apex' + [...Object.entries(this.BrokerRecord)]);
for (let [key, value] of Object.entries(data)) {
if (value != undefined)
this.BrokerRecord[key] = value;
}
Now, the apex class seems to not return anything with an 'List has no rows for assignment to sObject' in the bold line---- any clues? Its an LWC component hosted as a site and presently holds all permissions for Create/Read granted.