+ Start a Discussion
pierrefrazny.ax358pierrefrazny.ax358 

Set default value for StartDateTime for an Event

Hi,

 

I would like to set a default value for the Start Time and End Time when the user clicks New Event. I created a custom button with the following URL but the syntax I am used in the past for setting default values does not seem to work for this particular field (Start Time is not populated as expected).

Here is the URL:

/00U/e&retURL=%2F{!Assignment__c.Id}&cancelURL=%2F{!Assignment__c.Id}&what_id={!Assignment__c.Id}&&StartDateTime_time="8:00 AM"&EndDateTime_time="4:00 PM"

 

I would appreciate any clues.

Thanks

Pierre

Best Answer chosen by Admin (Salesforce Developers) 
apex whistlerapex whistler

Intersting. From what I can tell, you have to set BOTH the date and time field in order to set the time field. For example,

 

 

/00U/e?&retURL=%2F{!Assignment__c.Id}&cancelURL=%2F{!Assignment__c.Id}&StartDateTime=8%2F20%2F2010&StartDateTime_time="2:00 AM"

 

 

The Date has to be in mm/dd/yyyy format. Don't know if you need the date in the future or today, but you can use a formula to construct the date. From my testing if you use an incorrect date format, you'll get an error "invalid date format" but the time will update.

 

All Answers

apex whistlerapex whistler

Noticed that you have a double ampersand in your string (bolded and underlined below). For URL, an amerspand "&" is a special character to indicate a parameter/variable and value pair. Fix the ampersand and see if that works.

 

/00U/e&retURL=%2F{!Assignment__c.Id}&cancelURL=%2F

{!Assignment__c.Id}&what_id={!Assignment__c.Id}&&StartDateTime_time="8:00 AM"&EndDateTime_time="4:00 PM"

pierrefrazny.ax358pierrefrazny.ax358

I tried your siggestion and it did not work.

 

/00U/e?&retURL=%2F{!Assignment__c.Id}&cancelURL=%2F{!Assignment__c.Id}&StartDateTime_time="8:00 AM"&EndDateTime_time="4:00 PM"

 

Any other idea?

apex whistlerapex whistler

Intersting. From what I can tell, you have to set BOTH the date and time field in order to set the time field. For example,

 

 

/00U/e?&retURL=%2F{!Assignment__c.Id}&cancelURL=%2F{!Assignment__c.Id}&StartDateTime=8%2F20%2F2010&StartDateTime_time="2:00 AM"

 

 

The Date has to be in mm/dd/yyyy format. Don't know if you need the date in the future or today, but you can use a formula to construct the date. From my testing if you use an incorrect date format, you'll get an error "invalid date format" but the time will update.

 

This was selected as the best answer
pierrefrazny.ax358pierrefrazny.ax358

It worked indeed. Thank you for your help.

Pierre

Manish@SalesforceManish@Salesforce

I am unable to assign default value for StartDateTime. I am unable to recognize specific format used for time in context of current login user.

For user's having different local have different time format.Some examples are as below:

2:00 AM

2.00 AM

2:00AM

2.00AM

2.00 PDT

 

Can any body help me how to identify dynamically the time format and based on that it will automatically adjust the time with format.

Manish@SalesforceManish@Salesforce

Hard coding for StartDateTime_time is not working due to different locale for different users.

For user 's having match the time format 2:00 AM will work but for users having diffent time format than it will not work...

like 2:00AM or 2.0AM or 2.0 PDT or 2:00 PDT

Tim the WizardTim the Wizard
I know this thread is years old but I found it and it helped me to find a working solution in my environment. I used the following:
/00U/e?&retURL={!Contact.Id}&who_id={!Contact.Id}&evt5="Evening Call"&StartDateTime={!TODAY()} 
&StartDateTime_time="08:00 AM"&EndDateTime={!TODAY()} 
&EndDateTime_time="04:00 PM"

You can use the formula:  {!TODAY()}  to populate the start and end date as today's value. apex whistler is correct about there needing to be values in both StartDateTime, and StartDateTime_time for it to take the time value. Hope this helps someone. 
Jason MacFadyenJason MacFadyen
Thanks Tim the Wizard.  Your post was the only place I found this solution.