0

I've created a form which passes all the fields to the Sage CRM. I am also passing the browser date-time to the CRM field using Jquery when someone submits the form (this is to capture the date and time of form submission). The issue I am having is that the Sage CRM only accepts date dd/mm/yyyy format. If the user's browser date format is set up in mm/dd/yyyy format, the CRM is giving me an error(invalid date format).

I've also tried using PHP variables to pull the date and time from the server, but the CRM is not accepting the PHP as well.

I tried installing the WP date-time shortcode plugin and tried to pass the date via a shortcode, and it was not accepted by the CRM either.

Is there a way to achieve this? I've attached my form code below; any ideas or suggestions are welcomed.

<script type="text/javascript">
  function CreateAction()
 {
  if (document.WEB2LEAD.SELECTWorkFlow == null)document.WEB2LEAD.action = 
"http://crm.supremeheating.com.au/CRM/eware.dll/SubmitLead?RuleID=";
  else document.WEB2LEAD.action = "http://crm.supremeheating.com.au/CRM/eware.dll/SubmitLead?RuleID=" 
+ document.WEB2LEAD.SELECTWorkFlow.options[document.WEB2LEAD.SELECTWorkFlow.selectedIndex].value;
  return true;
}
function MergeFields() {
    var leaddetail = jQuery("#lead_detail").val();
    jQuery(".jointodetail").each(function(){
        if(jQuery(this).val()) {
            if(jQuery(this).data("label")){
                leaddetail += jQuery(this).data("label") + ": \n";
            }
            leaddetail += jQuery(this).val() + "\n";
        }
    });
    jQuery("#lead_detail").val(leaddetail);

    var lead_desc = jQuery("#lead_description").val();
    jQuery(".jointodesc").each(function(){
        if(jQuery(this).val()) {
            lead_desc += jQuery(this).val() + " - ";
        }
    });
    jQuery("#lead_description").val(lead_desc);

    company = jQuery("#lead_companyname").val();
    firstname = jQuery("#lead_personlastname").val();
    lastname =  jQuery("#lead_personfirstname").val();
    if(company == "") {
       jQuery("#lead_companyname").val(firstname + " " + lastname);
   }

    var mydate = new Date();
    jQuery("#lead_opened").val(mydate.toLocaleDateString());
    jQuery("#lead_openedtime").val(mydate.toLocaleTimeString());
    jQuery("#leadform").submit();
 }
</script>

<FORM Name="WEB2LEAD" id="leadform" method="POST" OnSubmit="return CreateAction();">
<TABLE CLASS=CONTENT WIDTH=100%>
  <TR>
   <TD>
      <SPAN ID=_Datalead_companyname class=VIEWBOX >
      <input type="text" CLASS=EDIT ID="lead_companyname" name="lead_companyname"  value="" 
          maxlength=60 placeholder="Company Name: *">
      <input type="hidden" name="_HIDDENlead_companyname" id="_HIDDENlead_companyname" value="" 
          entryType="10">
      </SPAN>
   </TD>
  </TR>
    .     
    .
    .
    .
 <TR>
   <TD>
      <SPAN ID=_Datalead_How_Can class=VIEWBOX >
      <textarea name="lead_How_Can"  ID = "lead_how_can" data-label="How can we help you" 
       class="jointodetail" rows=5 cols=30 placeholder='How can we help you?'></TEXTAREA>
      <input type="hidden" name="_HIDDENlead_How_Can" id="_HIDDENlead_how_can" value="" 
       entryType="11">
      </SPAN>
   </TD>
 </TR>
</TABLE>
<span class="submit">

<input type="hidden" name="lead_opened" id="lead_opened" value="" entryType="22">
<input type="hidden" name="lead_opened_TIME" id="lead_openedtime" value="" entryType="22">

<input type="hidden" name="RuleID" id="RuleID" value="">

<input type="button" value="Save and Submit" onClick="MergeFields();">
</span>

</FORM>

</BODY>

</HTML>

This the PHP variables I used to send the date to the CRM:

<input type="hidden" name="lead_opened" id="lead_opened" value="" entryType="22"> <input type="hidden" name="lead_opened_TIME" id="lead_openedtime" value="" entryType="22">

  • 1
    What do you mean the "CRM doesn't accept this"? You can definitely use the server time and adjust for timezone or JS to get current time. Show us how you tried getting the time using PHP or JS. You can also remove almost all that code from your question, since it is irrelevant. Just show us the field that you're trying to populate the date in. – disinfor Dec 17 '20 at 22:25
  • https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone – react_or_angluar Dec 17 '20 at 23:21
  • Hi, @disinfor thanks for replying, when the date is pushed in mm/dd/yyyy format it showing that it is an invalid format and the CRM is not accepting the form submission. Screenshot of the error message: https://ibb.co/9b7T8wX And this how I tried passing the PHP variables: " entryType="22"> " entryType="22"> – Hubert Jeffrey Dec 18 '20 at 02:03
  • @HubertJeffrey please add this code to your question, and not a comment. Also, look at your date echo, you are passing it in the wrong format. If the CRM wants dd/mm/yyyy, you are echoing it as mm/dd/yyyy - of course it will reject the date format. – disinfor Dec 18 '20 at 15:12

0 Answers0