function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mschmidtmschmidt 

set field to blank using sforce.connection.update()

Hello everybody,

I'm trying to set a record's field to blank using the function sforce.connection.update().
Here is my code:

Code:
newObject = new sforce.SObject("DocumentLink");
newObject.set("Id", linkedDocs[i]["Id"]);
newObject.set("Bookmark__c", bookmark);

// update Document Link object var result = sforce.connection.update([newObject]); for (var k=0; i<result.length ;k++ ){ if (result[k].getBoolean("success")){ } else { alert("Failed to store the bookmark changes! \n"+result[k]); } }

That works absolutly fine as long as bookmark is not empty.
But I want to be able to set the Bookmark__c field to be blank as well. How can a do that?
I tryed something link: bookmark=null and bookmark="". But non of them worked.

Seems like the method simply ignors the field if it is set to null or "".
Has anybody an idea??

Thanks,
Matthias

mschmidtmschmidt
I think I got it. :D

Setting bookmark = " " seems to do the job. A bit odd, isn't it!

Cheers,
Matthias
cheenathcheenath
I think you can just assign the field to null, like:

newObject.Bookmark__c = null;




jduhlsjduhls
Yes, "null" did not work, nor did empty quotes. But quotes with ONE space worked.  Must be some kind of proprietary crap.  Glad I found this forum post!
tendonstrengthtendonstrength

This seems to work in every browser but Chrome. When I try to save an object with one of the fields set to " " (with the space), I get a javascript error:

 

"Uncaught {faultcode:'soapenv:Client', faultstring:'Missing entity type information. sObject requires a separate 'type' field be sent.', }"

 

 This causes the save to fail completely. Does anybody happen to know the way of clearing a field that works in Chrome?

PenumakaPenumaka

Hi, I am also getting this same error with "Chrome" only. any updates on this issue?

 

thanks,

Ravi.

 

Omar MartinezOmar Martinez
You need to use the property of "fieldsToNull" representing an array of strings separated by commas to be cleaned database

http://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_concepts_core_data_objects.htm