You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using custom model objects with multiple queries, so I declared it like:
first {
let queries = ["SELECT Name FROM Account", "SELECT Id FROM Contact", "Select Owner.Name FROM Lead"]
return salesforce.query(soql: queries)
}.then { (results: [QueryResult<Record>]) -> () in
let accounts = results[0].records
let contacts = results[1].records
let leads = results[2].records
}.catch { error in
}
My problem is that all the objects are 'Record' and not either 'Account', 'Contact' or 'Lead', I tried a simple let accounts = results[0].records as? [Account] which gives me a warning "Cast from '[Record]' to unrelated type '[Account]' always fails"
The text was updated successfully, but these errors were encountered:
@auctifera-josed the issue is with Swift generics. QueryResult is defined as: QueryResult<T: Decodable>: Decodable
So you could substitute one of your Decodable model objects for Record e.g. QueryResult<Account> -- but I don't see how you could use 3 different Decodable types simultaneously. There may be a way via custom decoding and protocol inheritance, but seems like too much, unnecessary effort.
Try instead to create 3 separate queries and use the fulfill method for parallel execution -- see line 24 in Globals.swift
I'm using custom model objects with multiple queries, so I declared it like:
My problem is that all the objects are 'Record' and not either 'Account', 'Contact' or 'Lead', I tried a simple
let accounts = results[0].records as? [Account]
which gives me a warning "Cast from '[Record]' to unrelated type '[Account]' always fails"The text was updated successfully, but these errors were encountered: