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
advlgxadvlgx 

Error for End and Start fields saving a new Event record

This seems specific somehow to working with the Events Object. I want to create a new Event Record On click of custom Button(By passing some values). Problem: When I am passing the values for creating the record it gives an error in these fields EndDateTime,StartDateTime of Event Object. The values I am passing are legitimate DateTime fields from a custom object that have valid values.

I receive this error:
{errors:{fields:EndDateTime,StartDateTime, message:'Event: bad field names on insert/update call: EndDateTime, StartDateTime', statusCode:'INVALID_FIELD_FOR_INSERT_UPDATE', }, id:null, success:'false', }

My code is:

var eEvent=new sforce.SObject("Event");

eEvent.OwnerId="{!SE_Request__c.OwnerId}";

eEvent.WhatId="{!SE_Request__c.Id}";

if("{!SE_Request__c.ContactId__c}" != "")

{

eEvent.WhoId ="{!SE_Request__c.ContactId__c}";

}

if("{!SE_Request__c.LeadId__c}" != "")

{

eEvent.WhoId ="{!SE_Request__c.LeadId__c}";

}

eEvent.Description="{!SE_Request__c.Description__c}";

eEvent.DurationInMinutes=60;

eEvent.ActivityDate=date("{!Today}");

eEvent.ActivityDateTime=date("{!SE_Request__c.Preferred_Start_Date_Time__c}");

eEvent.StartDateTime=date("{!SE_Request__c.Preferred_Start_Date_Time__c}");

eEvent.EndDateTime=date("{!SE_Request__c.Preferred_Start_Date_Time__c}");

eEvent.ReminderDateTime=dateRem(my_time);

var result = sforce.connection.create([eEvent]);

var eEventAtt=new sforce.SObject("EventAttendee");

eEventAtt.AttendeeId="{!SE_Request__c.OwnerId}";

var resultAtt = sforce.connection.create([eEventAtt]);


Best Answer chosen by Admin (Salesforce Developers) 
advlgxadvlgx
Yes, did check that, thx. Funny, it seems to work in a developer edition account but not in the target org.

All Answers

CaptainObviousCaptainObvious
Have you checked the field level security, read/write permissions or validation rules on those fields?
advlgxadvlgx
Yes, did check that, thx. Funny, it seems to work in a developer edition account but not in the target org.
This was selected as the best answer