0

I have two remote actions. One returns the result set of an Account query. That Account query has a subquery for Assets, so for all intents and purposes, the query is [Select Id, (Select Id From Assets) From Account];. Any given Account in the result set from that query will look like {Id: "003450345k", Assets: Array(2)} or something like that in JSON.

The second remote action has a method signature of @RemoteAction public static void save(Account account) { ... }. When this remote action is invoked in JavaScript, it fails and reports a "Visualforce Remoting Exception: No such column 'Assets' on sobject of type Account"

Does anyone know of a way that you can do this? It would be really nice to be able to pass the child relationship collections of sObjects back to the server so that I don't need to re-query for them and do something like let {Assets, ...record} = account; and then invoke save(record); with the remainder account that effectively now has had Assets stripped out of it.

Both VF page and controller extension are api version 40.0

0

I'm pretty sure you can't use automatic serialization for this, but you could choose to do it yourself via JSON serialize/deserialize.

@RemoteAction public static String getAccount(Id recordId) {
    return JSON.serialize([SELECT Name, (SELECT Name FROM Assets)
            FROM Account WHERE Id = :recordId]);
}
@RemoteAction public static void doSomethingWithAccount(String jsonSource) {
    Account record = (Account)JSON.deserialize(jsonSource, Account.class);
    // ...
}
  • Thanks for the suggestion! I'm going to try it out in my app and I'll report back here on whether or not it behaved differently. – Matt Thomas Jul 11 '17 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.