Reputation: 1903
I currently am working on a site for a private school. They have a few netsuite forms that are implemented throughout the site to gather information from prospective students and parents.
Unfortunately we are having a bit of a difficult time coming up with a mobile solution of the netsuite forms. One solution my boss has suggested is constructing an HTML form and passing the data from that form over to Netsuite, where it would be parsed etc.
So I've constructed the html form, but have hit a bit of a wall.
Am I able to pass data over to netsuite? If so is it as simple as adding an action to the form with a specific netsuite form url?
From what I gather netsuite uses specific input fields such as etc. so how can this be done in html but passing the data back to netsuite? ajax (probably not due to same origin policy)? Form Action?
If none of these are at all plausible, what is a reasonable solution to get a mobile iteration of the netsuite forms?
<form name="consultation-form" id="ConsultationForm" method="post" action="http://www.netsuiteformaddress.com/maybe?">
Upvotes: 1
Views: 3599
Reputation: 3783
Have a look at this article, I believe it covers exactly what you are trying to do:
http://www.fmtconsultants.com/2014/05/the-best-way-to-integrate-external-web-forms-with-netsuite/
The basic idea is as you thought - to use a form post action to the external url of the form, and to name all the fields using their 'internalid'.
Upvotes: 1
Reputation: 924
You'll need to make the post to a php redirect file to avoid cross-origin problems:
Use this, and obviously replace the xxx with your account infromation.
<?php
session_start();
$url = 'https://forms.netsuite.com/app/site/crm/externalleadpage.nl?compid=xxxxxx&formid=xxx&h=xxxxxxxxxxxxxxxxxxxx';
$fields_string = '';
foreach($_POST as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
$fields_string = rtrim($fields_string,'&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($_POST));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
$result = curl_exec($ch);
curl_close($ch);
exit();
?>
Only issue is that it takes some time for the repost to be made. NetSuite is pretty slow to answer, so you might be looking at 4-8 sec response time.
The other solution would be a RESTlet, this is just simpler.
Upvotes: 2
Reputation: 1164
Look at implementing RESTlets in NetSuite to capture the form data. Take the form data, put it into JSON or XML, then call the RESTlet (a custom REST interface you create in NetSuite) with the JSON or XML in the payload.
The RESTLet can then parse the JSON and update any standard or custom table you create to store the data.
If you are familiar with NetSuite SuiteScript (JavaScript with NetSuite-specific libraries), you can have this working in no time.
Upvotes: 1
Reputation: 2480
I suppose that you have designed these HTML forms in a Netsuite Suitlet. Now you can receive the form data in the suitlet using following method
request.getParameter('field_name');
Upvotes: 1