Save attachment with Remote Objects

is it even possible to save attachment with remote objects to salesforce?

I tried this:

  1. construct remote object model

<apex:remoteObjects jsNamespace="MyModel">
<apex:remoteObjectModel name="Attachment" fields="Name,Id,ParentId,Body" >

  1. create attachment

var blob='test body';
var ctDetails = {Name:'test',parentid:'some_id',Body:blob};
var ct = new MyModel.Attachment();

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?


Based on the error message you get when you attempt to retrieve the body of an attachment:

Visualforce Remoting Exception: No serializer found for class common.udd.object.EncryptableFfxBlobField$DeferredEncryptableFfxBlobValueImpl

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…

  • Visual Force Remoting

    VF Remoting [does not] support Blob data type. See VF Remoting docs for supported types.

Source : Link , Question Author : Simon , Answer Author : Daniel Ballinger

Leave a Comment