So we was looking for a way to have a nice web based form for clients that would have specific questions that they would answer, like for a new hire, and once the form was completed it would create a ticket within Commit CRM assigned to the correct customer and reference (contract).

So we found this cool software called MachForms (Click here for feature list) that does a great job at creating web based forms that you can email on submission.  MachForms does a great job of emailing a pretty HTML formatted email but wouldn’t send a properly formatted XML document as was needed by Commit CRM.  With a little bit of tweaking to MachForms though we were able to get MachForms sending properly formatted XML and but doing some String Replacements we were able to get the Forms to create tickets in Commit assigned to the correct client and the correct reference (contract).

Part of the Web Request form that we created.

Below is the details on the files we had to modify on MachForms.

First we had to strip out some unnecessary formatting.

helper-functions.php

if($data['element_type'] == ‘textarea’){
$email_body .= “<b>{$data['label']}</b> <br />”.nl2br($data['value']).”<br /><br />\n”;
}elseif ($data['element_type'] == ‘checkbox’ || $data['element_type'] == ‘address’){
$email_body .= “<b>{$data['label']}</b> <br />”.$data['value'].”<br /><br />\n”;
}elseif ($data['element_type'] == ‘file’){
if($target_is_admin === false){
$data['value'] = strip_tags($data['value']);
$email_body .= “<b>{$data['label']}</b> – {$data['value']} <br />\n”;
}else{
$data['value'] = strip_tags($data['value'],’<a>’);
$email_body .= “<b>{$data['label']}</b> <br />”.$data['value'].”<br /><br />\n”;
}
}else{
$email_body .= “<b>{$data['label']}</b> – {$data['value']} <br />\n”;
}

change to:

if($data['element_type'] == ‘textarea’){
$email_body .= “{$data['label']} “.nl2br($data['value']).”\n”;
}elseif ($data['element_type'] == ‘checkbox’ || $data['element_type'] == ‘address’){
$email_body .= “{$data['label']} “.$data['value'].”\n”;
}elseif ($data['element_type'] == ‘file’){
if($target_is_admin === false){
$data['value'] = strip_tags($data['value']);
$email_body .= “{$data['label']} – {$data['value']} \n”;
}else{
$data['value'] = strip_tags($data['value'],’<a>’);
$email_body .= “{$data['label']} “.$data['value'].”\n”;
}
}else{
$email_body .= “{$data['label']} – {$data['value']} \n”;
}

Next we had to change from HTML to true Plain Text for XML emailing.

$mail->IsHTML(true);

Change to:

$mail->IsHTML(false);

Next we had to remove some additional formatting that is not needed for XML.

$email_content .= “<br /><br /><br /><br /><br /><b style=\”font-family:Lucida Grande,Tahoma,Arial,Verdana,sans-serif;font-size:12px\”></b>”;

Change to:

$email_content .= “”;

Next we had to add some string replacements, so that the customer and reference record ids in Commit would be added to the XML based on responses selected in the form.

$email_content = ‘<div style=”font-family:Lucida Grande,Tahoma,Arial,Verdana,sans-serif;font-size:12px”>’.$email_content.’</div>’;

Change to:

$email_content = str_replace(‘some form text‘, ‘Commit Customer Record ID ‘, str_replace(‘some other form text‘, ‘Commit Customer Record ID to replace for this additional form text‘, str_replace(‘some form text‘, ‘Commit Customer Record ID to replace for this additional form text‘, str_replace(‘some form text‘, ‘Commit Customer Record ID to replace for this additional form text‘, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(”some form text‘, ‘Commit Reference Record ID”, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(”some form text‘, ‘Commit Reference Record ID‘, str_replace(‘<br />’, ”, $email_content))))))))))));

We added multiple String Replacement commands, you can adjust to fewer or additional based on your needs.

Next, within MachForms we created a form and then in the email setup we created the Commit CRM XML template.


<?xml version=”1.0″ ?>
<?commitcrmxml version = “1.0″ ?>
<CommitCRMTransaction>
<ExternalApplicationName>MachForms</ExternalApplicationName>
<SendResponseToEmail>some email address</SendResponseToEmail>
<Password>Your XML API Password</Password>
<ReturnTransactionID></ReturnTransactionID>
<DataKind>TICKET</DataKind>
<RecordData>
<FLDTKTCARDID>{element_7}</FLDTKTCARDID>
<FLDTKTBCRECID>{element_17}</FLDTKTBCRECID>
<FLDTKTPROBLEM>New Hire Request</FLDTKTPROBLEM>
<FLDTKTSTATUS>100</FLDTKTSTATUS>
<FLDTKTKIND>General</FLDTKTKIND>
<FLDTKTNOTES>{entry_data}</FLDTKTNOTES>
<FLDTKTSOURCE>{element_14}</FLDTKTSOURCE>
<FLDTKTSCHEDLENESTIM>60</FLDTKTSCHEDLENESTIM>
<FLDTKTDUEDATETIME>{element_1}</FLDTKTDUEDATETIME>
<FLDTKTFORDISPATCH>Y</FLDTKTFORDISPATCH>
</RecordData>
</CommitCRMTransaction>

Have the form send into your email address that your Commit CRM system uses for automated emails and if everything is configured properly you will get an ticket created and assigned to the proper client and reference.

Since MachForms is great for sending other forms via HTML we setup two instances of MachForms, One for Commit Forms and the other for Standard HTML forms.  We could have built the logic in to utilize one for both but since the software is so inexpensive and easy to install we just setup two instances.

Dynamic Solutions Group provides assistance with Commit CRM implementations and integration projects.  Visit www.dsolutionsgroup.com for additional information.

Comments

No one has said anything yet.

Comments are closed.

© Copyright Dynamic Solutions Group, Inc. All Rights Reserved.

Website Design, Graphic Design and Search Engine Optimization by Dynamic Solutions Group, Inc.