I want to create an Event from Visual Flows, and in that I need to generate an Event with fixed Time but for a Date read from another record ( a custom object).

The idea is to click a Button and it executes a Flow, and it reads the record it is clicked from and it stores the field "StartEventDate__c" into a variable and then create an Event with all required value of event passed and the Event Start DateTime set to "StartEventDate__c + 7:59 AM" of logged in user's time.


Yes, you can do that with a visual flow. It's simply evaluating a formula where the Event's StartDateTime, depending on how you set it up, evaluates using a formula similar to:

DATETIMEVALUE( TEXT( MONTH( Today() ) ) & "/" & TEXT( DAY( Today() ) ) & "/" & TEXT( YEAR(Today() ) ) & TEXT(7:59 AM) )  

Using Apex code it would be much simpler, but you might need to create an Apex Plugin to do that. Not certain on the need for the plugin as I've only used flow a couple of times.

You might be able to get away with a formula that's as simple as:


If I were using Apex, I'd do something like:

StartDateTime = DateTime.parse(format(today()) +' 7:59 AM'); 

So, the actual methodology would depend largely on how you construct the logic of your flow and the variables you set it up to work with. Hope this gives you a few ideas to get you started.


Since you're passing StartEventDate__c into your flow instead of Today(), it's assuming DateField__C can hold any date you might enter whether its valid or not. You're going to need to add some logic to reflect that. Tips on how to do what you need is contained in Using Date and Date/Time in Formulas, including how to get leap years. You might also find this document helpful to you as well Tips for Reducing Formula Size.

| improve this answer | |
  • cool. I actually tried and failed assigning datetime from URL so was wondering the correct format acceptable here. I'll try these and let you know. – VarunC Apr 22 '14 at 6:21
  • I have passed in like DateParameter={!DATETIMEVALUE( TEXT( MONTH( DateField__c ) ) & "/" & TEXT( DAY( DateField__c ) ) & "/" & TEXT( YEAR(DateField__c ) ) & " 7:59 AM" )} on button. DateParameter is a Variable which i have declared in Flow. Error i received is Invalid Date Computed an invalid date, such as February 29th on a non-leap year. Please contact your administrator; formula fields can cause such errors. – VarunC Apr 22 '14 at 7:51
  • That makes sense. Its assuming DateField__C can hold any date whether its valid or not. You're going to need to add some logic to reflect that. Tips on how to do what you need is contained in this document (including getting leap years): developer.salesforce.com/docs/…. – crmprogdev Apr 22 '14 at 13:27
  • This is a great workaround. Please be aware that the new date value stored is in system context, not in user context, so you might need to do some manipulation on it. – westerforce Apr 20 '15 at 7:05
  • All Date and DateTime values are stored in the database in UTC or system context. However, when they're displayed, they'll be converted to the User's Time Zone. – crmprogdev Apr 20 '15 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.