2

I have a Master Object A...

...And a Child Object B with a Master-Detail field A__c pointing to A...

...I'm trying to create a B record, child of a pre-existent record A using Remote Objects...

...so I create my B record in Javascript and then call the .create() function...

var record = new MYNS.B({Name: 'blabla', A__c: 'a08U000000jFvPR'}); record.create(...);

...but my record is not created because VF Remoting complains that the field A__c (the Master-Detail field) is not writeable even if I'm creating and not updating the record...

...I suppose that's because under the hood the Salesforce Remote Object standard Controller class is using Dynamic Apex and SObject.put() to fill/create the SObject on the Apex side, and that exactly wouldn't work to handle the case - we'd need to use the specific SObject constructor to fill our field:

B__c record = new B__c(Name = 'Blabla', A__c = 'a08U000000jFvPR');

...I guess if I was to set the Master-detail as reparentable the error would disappear, but that's not what I want...

...so am I missing something, or what can I do to overcome this problematic Remote Objects behavior with Master-Detail fields without recurring to a Remote Action Override?

1 Answer 1

2

I have created records with Master-Detail relationships via RemoteObjects.

I only have examples within AngularJs using ngRemote (https://github.com/florianhoehn/ngRemote) - not sure if that helps you here.

But one tip: make sure you have the Master-Detail field inside the remoteObject definition fields - otherwise it will not work.

Hope this helps.

1
  • Hey, thanks for the tip and the head up about ngRemote - interesting library. I am exactly in the middle of something similar. Anyway, the Master-Detail field is already in the RemoteObject fields definition, so I'm still left with no clue about what's wrong in my setup (And without much time to experiment on it!).
    – MLucci
    Commented Dec 15, 2015 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .