• TroyNimbly
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I'm having trouble with the following code, for date fields only.  I assume it is because the date is not formatted correctly when passing the sobject json to the remote action.  I have tried a few different formats and there seems be a concensus that the date-time format is  ISO8601.  This is fine, but the middle option is formatted with ISO8601 and no dice.  

 

I am using the javascript date() to format the strings as well.

 

This does work for normal string/picklist fields, so that is why I am seeking help for the date field values.  Any help is greatly appreciated.

 

controller:

@RemoteAction
global static void setField(sObject obj) 
{
	upsert obj;
}

 

 

json:

var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "2013-08-26"};
or
var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "2014-06-23T07:00:00.000Z"};
or
var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "6/23/2014"}

 

 

js function;

Controller.setField(sObj, function(result, event){
		if (!event.status && event.type == "exception") {

			$j("[id$=':msgs']").text("Unable to save meeting preference:" + event.message).show();
		}
});

 

 

 JSON received in chrome js console:
action: "Controller"
data: Array[1]
message: "Unexpected type for Controller.setField(SObject)"
method: "setField"
ref: false
result: null
statusCode: 400
tid: 15
type: "exception"
vfDbg: true
vfTx: true
where: ""
__proto__: h
 
and:
$VFRM.Util.error VFRemote.js:114
(anonymous function) VFRemote.js:130
a.Event.fire VFRemote.js:50
a.Observable.fireEvent VFRemote.js:45
VFExt3.Direct.VFExt3.extend.onProviderData VFRemote.js:84
a.Event.fire VFRemote.js:50
a.Observable.fireEvent VFRemote.js:45
VFExt3.direct.RemotingProvider.VFExt3.extend.onData VFRemote.js:92
VFExt3.extend.handleResponse VFRemote.js:73
a VFRemote.js:37
(anonymous function)
 

 

I'm having trouble with the following code, for date fields only.  I assume it is because the date is not formatted correctly when passing the sobject json to the remote action.  I have tried a few different formats and there seems be a concensus that the date-time format is  ISO8601.  This is fine, but the middle option is formatted with ISO8601 and no dice.  

 

I am using the javascript date() to format the strings as well.

 

This does work for normal string/picklist fields, so that is why I am seeking help for the date field values.  Any help is greatly appreciated.

 

controller:

@RemoteAction
global static void setField(sObject obj) 
{
	upsert obj;
}

 

 

json:

var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "2013-08-26"};
or
var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "2014-06-23T07:00:00.000Z"};
or
var sObj = {id: "003Xxxxxxxxxxxxx", Date_of_Next_Meeting__c: "6/23/2014"}

 

 

js function;

Controller.setField(sObj, function(result, event){
		if (!event.status && event.type == "exception") {

			$j("[id$=':msgs']").text("Unable to save meeting preference:" + event.message).show();
		}
});

 

 

 JSON received in chrome js console:
action: "Controller"
data: Array[1]
message: "Unexpected type for Controller.setField(SObject)"
method: "setField"
ref: false
result: null
statusCode: 400
tid: 15
type: "exception"
vfDbg: true
vfTx: true
where: ""
__proto__: h
 
and:
$VFRM.Util.error VFRemote.js:114
(anonymous function) VFRemote.js:130
a.Event.fire VFRemote.js:50
a.Observable.fireEvent VFRemote.js:45
VFExt3.Direct.VFExt3.extend.onProviderData VFRemote.js:84
a.Event.fire VFRemote.js:50
a.Observable.fireEvent VFRemote.js:45
VFExt3.direct.RemotingProvider.VFExt3.extend.onData VFRemote.js:92
VFExt3.extend.handleResponse VFRemote.js:73
a VFRemote.js:37
(anonymous function)