4.2 - Removing a File Upload from a record

Posted by Meryk on 17-Jun-2016 06:18

Hello,

I have a File Upload field in an object myObject and I am trying to remove a file upload from a given record from a trigger.

How can I achieve that please?

I tried doing rbf_updateRecord() this way, but it doesn't work.

var arr= [];

var emptyObject = {}

arr['fileUploadField'] = emptyObject;

rbv_api.updateRecord('myObject', myRecordId , arr);

I also came accross this method : rbv_api.setBinaryFieldValue(objName, objId, fieldname, encodedValue, contentType, fileName). That looks like the one to be used to set a file. 

But can I use it to remove the existing file upload in the record?

Thank you

Meryem

Posted by Mohammed Siraj on 20-Jun-2016 04:15

Meryem, was commenting on reasons behind rbv_api.updateRecord not giving the desired result.

However, to acheive the desired behavior in 4.2, you can write an ObjectScript trigger and use setFieldValue server-side API.

Eg:

rbv_api.setFieldValue("testFileUpload", {!id}, 'testFile', null);

All Replies

Posted by Mohammed Siraj on 18-Jun-2016 05:27

Ideally, rbv_api.updateRecord('myObject', myRecordId , {fileUploadField: null}); should have sufficed. However, there is a limitation in Rollbase wherein we do not unset FileUpload field value.

This is done to preserve any existing FileUpload filed value in case of form submits wherein the FileUpload field is not re-submitted each time the record is edited.

Request you to file a support case in this regard i.e. unset FileUpload field value via API.

Also, use rbv_api.setBinaryFieldValue(objName, objId, fieldname, encodedValue, contentType, fileName) only for SET case & not an unset case like this.

Posted by Meryk on 20-Jun-2016 03:22

Hi Siraj,

Thanks for the reply. So what you are saying is that this is not achievable in 4.2, correct?

I am opening a support case. Thanks.

Cheers,

Meryem

Posted by Mohammed Siraj on 20-Jun-2016 04:15

Meryem, was commenting on reasons behind rbv_api.updateRecord not giving the desired result.

However, to acheive the desired behavior in 4.2, you can write an ObjectScript trigger and use setFieldValue server-side API.

Eg:

rbv_api.setFieldValue("testFileUpload", {!id}, 'testFile', null);

Posted by Meryk on 20-Jun-2016 04:29

I did try this Siraj. It is not setting the file to Null.

Thanks,

Meryem

Posted by Meryk on 20-Jun-2016 05:32

Hi Siraj,

rbv_api.setFieldValue("testFileUpload", {!id}, 'testFile', null); is working in an object script trigger in the same object where we want to empty the upload file. Which is fine for the moment.

It was not working in my case as the trigger was in a related object. Not sure why it is behaving like this. But I am fine with having the trigger in the same object as well.

Thank you

Meryem

This thread is closed