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
Bushra ZainuddinBushra Zainuddin 

Quick action on Events object not working when start and end date are predefined

I have a use case to auto populate start and end date on an object specific action on Events. I also need to remove these two fields from the layout. If I remove the fields from ththe layout, it does not let me create a new event by throwing an error which states that required fields are missing I.e. start and end date. 

Am am I missing something here? What else should I do to make sure that the form works successfully  without displaying the fields on the layout and having them auto populate using predefined valued.
Waqar Hussain SFWaqar Hussain SF

You can develop a before insert trigger on the object to autopopulate these two fields.

Lets suppose, you have a custom object named Contract__c and on this object you have two fields Start_Date__c and End_Date__c

So the trigger will work as below
 

Trigger ContractTrigger on Contract__c(Before insert) {
    for (Contract__c cont: trigger.new) {
        cont.Start_Date__c = system.today();
        cont.End_Date__c = system.today().addDays(30);
    }
}
 

Let me know If it works.

Bushra ZainuddinBushra Zainuddin
I was able to work it out. When predefining Start and End Date for Events on a Quick Action, we also need to set a predefined value on ActivityDate and Durationinminutes. I set both to a generic value and it worked.
Waqar Hussain SFWaqar Hussain SF
Great :)