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
dhetzerdhetzer 

Creating Events via the API

HELP!   I can't for the life of me seem to create an Event via that API.  
When i try to .Create() the following Event object:

   AccountId: Nothing
   ActivityDate: #8/27/2003 3:30:00 PM#
   ActivityDateSpecified: False
   ActivityDateTime: #8/27/2003 3:30:00 PM#
   ActivityDateTimeSpecified: False
   CreatedById: Nothing
   CreatedDate: #12:00:00 AM#
   CreatedDateSpecified: False
   Description: ""
   DurationInMinutes: 120
   DurationInMinutesSpecified: False
   fieldsToNull: Nothing
   Id: Nothing
   IsAllDayEvent: False
   IsAllDayEventSpecified: False
   IsChild: False
   IsChildSpecified: False
   IsGroupEvent: False
   IsPrivate: False
   LastModifiedById: Nothing
   LastModifiedDate: #12:00:00 AM#
   LastModifiedDateSpecified: False
   Location: "0"
   MarketingEvent__c: ""
   OwnerId: "00530000000c3kG"
   Prescreen__c: ""
   RequestedFulfillment__c: ""
   Subject: "Meet with Tamara and Garfield"
   SystemModstamp: #12:00:00 AM#
   SystemModstampSpecified: False
   Type: "Other"
   WhatId: Nothing
   WhoId: "00Q30000001j2dMEAQ"

 

I get this:

{sforce.Error}
    fields: {Length=1}
    message: "You must enter a value"
    statusCode: REQUIRED_FIELD_MISSING
    fields: {Length=1}

with no mention of which required field is missing --
has anyone seen/resolved this before?   I'm using API version 2.0

I'm assuming the ActivityDateSpecified, LastModifiedDateSpecified, etc fields are FALSE because this Event has not yet been posted to the server, and they are not createable.

Thanks in advance for any help at all with this

DevAngelDevAngel

Hi dhetzer,

If you are trying to set all the fields that you show in your post, it will fail, even when setting the field that is required that is not mentioned in the error. 

So, minimally to create an event you will need to set the following:

ActivityDate or ActivityDateTime (ActivityDateSpecified = true or ActivityDateTimeSpecified = true)

If you use ActivityDate, then you also need to set the IsAllDayEvent and IsAllDayEventSpecified to true.  Otherwise, the system thinks you are setting an event that needs a time element, in which case you can use the ActivityDateTime and ActivityDateTimeSpecified, DurationInMinutes and DurationInMinutesSpecified fields.

Any time you set a Date or Numeric value in .Net, you also need to set the ...Specified field to true to have the value included in the SOAP message.  This is a .Net requirement, not ours.

To summarize (at a minimum),

For an all day event set ActivityDate, ActivityDateSpecified = true, IsAllDayEvent = true, IsAllDayEventSpecified = true.

For a time constrained event set ActivityDateTime, ActivityDateTimeSpecified = true, DurationInMinutes, DurationInMinutesSpecified = true.