Jump to content
X2Community Forums

New custom fields values are updating as null during form post


Recommended Posts

Hi All,
 
I have created a form in word press from there when a user submits the details, it will get displayed in Contact module(via API). it was working fine with the default database attributes.
 
I tried to add custom fields to the database from X2CRM->Manage Fields. it got successfully created in the database. when I try to add values to the new attributes through the form. except for the new custom fields, rest of attributes got updated.
 
below are the new values which got added to x2_contacts through Manage fields
 
c_occupation Occupation Contacts No varchar No     c_investortype Investment Type Contacts No varchar No     c_investmentamt Investor amount Contacts No varchar No
 
help?
 
 
 
PHP code
 
<?php
file_put_contents('test1.txt', json_encode($_REQUEST) );
$username = "dummy";
$password = "234wfsfsq3432efxvae234323";
$contact = array(
    "firstName" => $_POST["First_Name"],
    "lastName" => $_POST["Last_Name"],
    "email" => $_POST["Email"],
    "phone" => $_POST["Phone"],
   "company" => $_POST["Company"],
"country" => $_POST["Country"],
"linkedin" => $_POST["Linkedin"],
"Occupation" => $_POST["c_occupation"],
"Investment" => $_POST["c_investmentamt"],
"Type" => $_POST["c_investortype"],
"backgroundInfo" => $_POST["Comments"],
    "visibility" => 1
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8;"));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
$data = json_encode ($contact);
curl_setopt($ch, CURLOPT_POST, $data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
 
//Actual Call to Server
$server_output = curl_exec ($ch);
?>
 
 
Database entry
 
| id | name        | nameId        | firstName | lastName | title | company   | phone | phone2 | email          | website | address | address2 | city | state | zipcode | country   | visibility | assignedTo | backgroundInfo | twitter | linkedin  | skype | googleplus | lastUpdated | lastActivity | updatedBy | priority | leadSource | leadDate | rating | createDate | facebook | otherUrl | leadtype | closedate | expectedCloseDate | interest | leadstatus | dealvalue | leadscore | dealstatus | timezone | doNotCall | doNotEmail | trackingKey                      | dupeCheck | fingerprintId | reverseIp | c_investmentamt | c_investortype | c_occupation |
 

 

Link to post
Share on other sites

I believe that you'll want to update your $contact array to use the custom field names as the keys as well. For example, you'll want to update the line:

"Occupation" => $_POST["c_occupation"],

to:

"c_occupation" => $_POST["c_occupation"],

The keys in the POST data will be used to lookup the model's fields, so for custom fields, you'll want to be sure to include the "c_" prefix.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...