Pages

2012/01/17

Use of an Online Customer Form as a URL listener to create Leads in NetSuite

Here is a little trick to use the built-in NetSuite Online Customer Form to receive data from an URL and create a NetSuite Lead. This is accomplished without a click from the end-user, and without their knowledge of going through NetSuite.

By avoiding the use of a script (Suitelet), this allows for easier customization and less implementation time, as setup and maintenance can be done by someone with only limited HTML knowledge. The main application of this trick is online advertising or re-use of an existing Contact Us form; as soon as you generate an URL with proper parameters, you can create a Lead in NetSuite!

In this tutorial, we will create a NetSuite Lead for customer Carey Price of the company ERP Guru having the email test.mail@erpguru.com

This tutorial has 3 parts:
  1. Set-up the Online Customer Form in NetSuite
  2. Write some hacked HTML
  3. Test-it!
Note: this is a hack, unsupported by NetSuite.

PART 1: SET-UP THE ONLINE CUSTOMER FORM IN NETSUITE

1) Create a New Online Customer Form:
Setup > Marketing > Online Customer Forms > New and choose "Custom HTML Template"

2) In the “Select Fields" tab of the newly created Online Customer Form, add the fields you need to populate in the future NetSuite Lead.
Add First Name, Last Name, Company Name and Email. For every field, be sure to select "Hide = Yes":







felix_post_jan_17_2012_image1

Note: Keep in mind that problems with mandatory fields will be displayed in a page with a NetSuite logo, which kind of "breaks" the invisibility of the whole process.




3)In the "Set Up Workflow" tab of the Online Customer Form, indicate what NetSuite should do once it receives the date from the URL.


For this example we will choose to create a "Unqualified Lead", with the source set to "Web". (It is also possible to notified a Sales Rep if so desired)







felix_post_jan_17_2012_image2

The beauty of this tab is the "Redirect to URL" field, where it is possible to choose a page where end-user will land without knowing that a Lead was created in NetSuite.




PART 2: WRITE THE HTML CODE


4) The next step is the creation of a form template that contains the "hacked" HTML code our Online Customer Form will use.


In the Online Customer Form, click on the field "Template" and select "New":







felix_post_jan_17_2012_image3


You will be directed to the "Online Form Template" page, where you need to paste the HTML code from the step below.





felix_post_jan_17_2012_image4


5) The HTML code you need to paste in your Online Form Template has 2 important sections:

A: A <NLFORM></form> section containing every field used in step 2 of this tutorial. In the example at step 2, First Name, Last Name, Company Name and Email were used. Thus the HTML template will contain <NLFIRSTNAME>, <NLLASTNAME>, <NLCOMPANYNAME>, and <NLEMAIL>.

B: A custom code placed AFTER the </html> tag, which will override the window.onload function inserted by NetSuite, will submit the form as soon as it's loaded.

The creation of a function "submitLead" is recommended, to be called by window.onload as seen in the below image.

Please note that by default the form name created by NetSuite is main_form. This name is used when writing document.forms[« main_form »].submit(); that submits the form.







felix_post_jan_17_2012_image5

You can download the template used for this example HERE.

PART 3: TEST IT!


6) Save the Online Customer Form and go to it's 'External' tab to get the Publishable Form URL
This URL should begin with "https://forms.netsuite.com/app/site/crm/externalleadpage.nl?"

7)Append parameters to this URL with "&".

In the example in step 2, the fields First Name, Last Name, Company Name and Email were used. Thus the following parameters need to be appended to the Publishable Form URL:

&firstname=Carey&lastname=Price&companyname=ERP Guru&email=test.mail@erpguru.com


8) Paste the complete URL in your browser, press Enter and go to your NetSuite Lead List:

Example:
https://forms.netsuite.com/app/site/crm/externalleadpage.nl? compid=0000000&formid=2&h=00000000000007e565a1&firstname=Carey&lastname=Price &companyname=ERP Guru&email=test.mail@erpguru.com


The lead "Carey Price" is created in NetSuite without the need of a single click. Notice that you should have landed on the Online Customer Form "redirect to URL" without seemingly going through NetSuite.


WHY THIS IS MAGIC:
You can add fields with NetSuite's UI and adjust the form template with basic HTML knowledge, all without scripting!

KNOWN IMPACT OF THIS HACK:
When generating the Online Customer Form, NetSuite adds a bunch of generic code. As we override the window.onload function, the page_init() function added by NetSuite is never called. Thus, you may need to add some code to your custom submitLead function.


For your information, here is the content of the page_init() never called:

*************************************************
function page_init() {
window.weekstart ='1';
window.dateformat ='DD-Mon-YYYY';
window.longdateformat ='DD Month YYYY';
window.timeformat ='fmHH24:fmMI';
window.timeformatwithseconds ='fmHH24:fmMI:SS';
window.datetime_am_string ='am';
window.datetime_pm_string ='pm';
window.datetime_short_months = new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","");
window.phoneformat ="(123) 456-7890";
window.isvalid = true;
setWindowChanged(window, false);
setIsInited(window,false);
page_init2();
page_init3();
setWindowChanged(window, false);
page_init4();
setIsInited(window,true);
window.status = '';
}
function page_init2() {
}
function page_init3() {
}
function page_init4() {
nlapiPageInit('create');
nlapiSetFieldValue('nsbrowserenv', 'istop=' + (window==top ? 'T':'F'));
}

**********************************************

Written by: Félix Guinet

Special thanks to Guillaume Bouchard Lafond and Pablo Herrera

4 comments:

  1. What is the purpose?
    Why create the same lead over and over again.
    Where is the business use?

    ReplyDelete
  2. Hi anonymous,

    Depending on the parameters you place in the URL, a different Lead will be created. The main purpose of this trick is to re-use an existing Contact Us form without having to blend a NetSuite form into your existing website.

    This can be very useful in order to track Lead sources too. For example, add a parameter like &source=google or &source=bing or &source=emailcampaing99 to the URL, coupled with custom field on Customer record. In no time and without having to script a Suitelet / Restlet, you have a working solution to create Leads and track where they are coming from.

    Regards,
    Félix

    ReplyDelete
  3. Thanks so much for this Felix

    ReplyDelete
  4. Hi guys,

    I just released a new "version" of this trick, using a POST request :

    2013/09/03 : Connect your Contact Us Page from your Website to Netsuite

    http://blog.erpguru.com/2013/09/connect-your-contact-us-page-from-your.html

    Cheers,
    Felix

    ReplyDelete