Last active
May 23, 2016 21:04
-
-
Save zackkatz/ae3924779157261b80e3 to your computer and use it in GitHub Desktop.
Use DateTime for Gravity Forms Salesforce Web-to-Lead Addon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 1. Tell the plugin to use DateTime instead of Date for the "MyPrefix__Date_and_Time__c" field | |
* | |
* @param string $boolean Whether to use DateTime instead of Date (default: false) | |
* @param string $key The Field Name (or API Name if a custom field) used in Salesforce | |
* @param array $additional_info Associative array with form, entry, field, feed data | |
*/ | |
function modify_gf_salesforce_use_datetime( $boolean = false, $key = '', $additional_info = array() ) { | |
// Use your own Field Name or API Name below instead of the "MyPrefix__Date_and_Time__c" | |
// If it matches, DateTime will be used | |
if( $key === 'MyPrefix__Date_and_Time__c') { | |
return true; | |
} | |
return $boolean; // Otherwise, Date will be used by default | |
} | |
add_filter('gf_salesforce_use_datetime', 'modify_gf_salesforce_use_datetime', 10, 3 ); | |
/** | |
* 2. Change the date format (optional) | |
* | |
* If the date format isn't working for DateTime, you can modify it here. | |
* Use the format shown here for your country: | |
* @link https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_supported_locales.htm | |
*/ | |
function modify_gf_salesforce_datetime_format( $format ='Y-m-d H:i:s' ) { | |
/** | |
* Use a different format, using the Date Time Formats shown here: | |
* @link http://codex.wordpress.org/Formatting_Date_and_Time | |
*/ | |
return 'c'; | |
} | |
add_filter('gravityforms/salesforce/datetime_format', 'modify_gf_salesforce_datetime_format'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this a working solution to the following error?
2016-05-23 17:03:07.973458 - ERROR --> GFSalesforce::create:
Exception While Exporting Entry
There was an error exporting Entry #1145 for Form #38. Here's the error:
'2016-05-23 21:03:06' is not a valid value for the type xsd:dateTime
2016-05-23 17:03:07.983292 - DEBUG --> GFSalesforce::export_feed: Lead failed to be created/updated