You need to sign in to do that
Don't have an account?
picker
Create an event using AJAX
Can anyone tell me why this bit of code does not create a new event?
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script type="text/javascript" src="https://na1.salesforce.com/js/functions.js"></script>
<script>
sforceClient.init("{valid session id}", "{valid server}", true);
<script type="text/javascript" src="https://na1.salesforce.com/js/functions.js"></script>
<script>
sforceClient.init("{valid session id}", "{valid server}", true);
var vappt;
vappt = new Sforce.Dynabean("event");
vappt.set("WhoId","{valid contact id}");
vappt.set("WhatId","{valid account id}");
vappt.set("Subject","Appointment Set");
vappt.set("Location","ADDRESS NOT FOUND");
vappt.set("IsAllDayEvent","false");
vappt.set("ActivityDateTime",new Date("2006-08-02T13:00:00+00:00"));
vappt.set("DurationInMinutes","30");
vappt.set("Description","anything");
var appt_sr2 = sforceClient.create([vappt])[0];
vappt = new Sforce.Dynabean("event");
vappt.set("WhoId","{valid contact id}");
vappt.set("WhatId","{valid account id}");
vappt.set("Subject","Appointment Set");
vappt.set("Location","ADDRESS NOT FOUND");
vappt.set("IsAllDayEvent","false");
vappt.set("ActivityDateTime",new Date("2006-08-02T13:00:00+00:00"));
vappt.set("DurationInMinutes","30");
vappt.set("Description","anything");
var appt_sr2 = sforceClient.create([vappt])[0];
</script>
so,
alert(appt_sr2.toString())
mabey take off the [0] at the end of the create() to see the entire fault message
OK, i found the solution. The confusion came about because i am using both the java API and the ajax API. The dateTime string that i was trying to use is formatted correctly if i were using java. For AJAX and javascript, i did this:
var vdate = new Date();
vdate.setYear("2006");
vdate.setMonth("07");
vdate.setDate("05");
vdate.setHours("13");
vdate.setMinutes("00");
vdate.setSeconds("00");
document.write(vdate);
vappt.set("ActivityDateTime",vdate);
look for Sforce.Util.parseDate() and you will find it, and several other usefull date routines.