is it even possible to save attachment with remote objects to salesforce?
I tried this:
- construct remote object model
<apex:remoteObjects jsNamespace="MyModel">
<apex:remoteObjectModel name="Attachment" fields="Name,Id,ParentId,Body" >
</apex:remoteObjectModel>
</apex:remoteObjects>
- create attachment
var blob='test body';
var ctDetails = {Name:'test',parentid:'some_id',Body:blob};
var ct = new MyModel.Attachment();
ct.create(ctDetails);
I get response:
Body: value not of required type...
I thought problem has to be with body encoding and I tried to convert to base64 (btoa('test body')), use Blob class in javascript. Nothing works, response is the same everytime.
What is wrong here?
Best Answer
Based on the error message you get when you attempt to retrieve the body of an attachment:
It would appear that you can't work with blob fields in Visualforce Remote Objects.
I'll see if I can find an official reference for the supported field types...