user1362148
user1362148

Reputation: 11

Pushing A Webform Into vTiger

I've created a webform that is outside of vTiger that I want to push into the database that vTiger uses.

This is the SQL code that pushes the data into the database:

$sql="INSERT INTO vtiger_potential(potentialname)VALUES('$company_name', '$potential_no')";

And this is the error that I seem to be getting:

Cannot add or update a child row: a foreign key constraint fails (`vtigercrm530/vtiger_potential`, CONSTRAINT `fk_1_vtiger_potential` FOREIGN KEY (`potentialid`) REFERENCES `vtiger_crmentity` (`crmid`) ON DELETE CASCADE)

Any ideas on how to fix this?

Upvotes: 1

Views: 1932

Answers (1)

hpaknia
hpaknia

Reputation: 3118

  1. Why don't you use webforms module. Simply you create your web form with some rules and then send the form to 'your site link'/modules/Webforms/post.php . The advantage is that all the job is done by crm basic functions and all security measures are ensured (be careful about user input data!!!) an example form of Webforms is like:

enter image description here

also you can add other inputs with corresponding names in Leads module. for custom fields you can check names by firebug (cf_*). 2. If you want to do it in database consider that all of the vtiger entities (contacts, leads, etc) has a specific id in crm_entity, so crm_entity holds all the ids of different entities. Before creating a lead entity, you must create its crm_entity row and then pass new_insert_id to Leads pertinent tables. But be careful in case of any future problem in crm you may not be sure it's your fault (direct manipulation of database) or not!

Upvotes: 1

Related Questions