You need to sign in to do that
Don't have an account?
jojoforce
javascript remoting sobject with date
I have a javascript remoting with an sObject that has a date function, however, it doesn't seem like it likes the date. How do I pass an sobject with Date?
VF Page
I tried different variation in handling javascript date format...Nothing seems to work....Any advice would be great!
VF Page
function MyObject__c() { this.name = null; this.Start_Date__c = null; this.End_Date__c = null; } function createRecord() { MyObject__c myobj = new MyObject__c(); myobj.Start_Date__c = '2017-01-01'; myobj.End_Date__c = '2017-01-31'; Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.myclass.mymethod}', myobj, function(results, event){ if (event.status) { console.log(results); } }, {escape: true} ); }Apex Controller
global class myclass { @RemoteAction global static void myAction(MyObject__c myobj) { insert myobj; } }
I tried different variation in handling javascript date format...Nothing seems to work....Any advice would be great!
myobj.Start_Date__c = new date('2017-01-01'); myobj.End_Date__c = new date('2017-01-31');
myobj.Start_Date__c = new date('2017-01-01').toUTCString(); myobj.End_Date__c = new date('2017-01-31').toUTCString();
Alain Cabon
Hi,