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
bolaurent.ax1262bolaurent.ax1262 

how to set a field to null from javascript remote?

I'm trying to set a database field to null from a javascript remote.

 

{!REQUIRESCRIPT('/soap/ajax/22.0/connection.js')}
{!REQUIRESCRIPT('/soap/ajax/22.0/apex.js')}
var __sfdcSessionId = '{!GETSESSIONID()}';

updater= new sforce.SObject("Account");

updater.id='{!Account.Id}';
updater.Stage_Expiry_Date__c = "";

resultC = sforce.connection.update([updater]);

 Above does not work.

 

The API documentation for update says "add the field name to the fieldsToNull array in the sObject." But I can't seem to figure out how to to that from javascript:

 

updater.fieldstoNull.push("Stage_Expiry_Date__c");

 Produces the message "updater.fieldsToNull undefined."

 

How can I set a field to null from javascript remotey?

 

 

Navatar_DbSupNavatar_DbSup

Hi,


Try the below code snippet as reference:

 

{!REQUIRESCRIPT('/soap/ajax/22.0/connection.js')}
{!REQUIRESCRIPT('/soap/ajax/22.0/apex.js')}
var __sfdcSessionId = '{!GETSESSIONID()}';
updater= new sforce.SObject("Account");
updater.id='{!Account.Id}';
updater. Stage_Expiry_Date__c= null;
resultC = sforce.connection.update([updater]);
window.location.reload();

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.