We implemented NetSuites recommended method for capturing a lead's ip address. However now when we run the code thru a debugger we get an error message of "Uncaught TypeError: Cannot call method 'setAttribute' of null"
Can anyone tell me how to remove this error?
Below is the code that is causing the error message.
<script language="javascript" type="text/javascript">
document.getElementById("custentity10").setAttribute("value","<%=getCurrentAttribute('request','ipaddress')%>");
document.getElementById("custentity10_fs_lbl").style.display = "none";
document.getElementById("custentity10_fs").style.display = "none";
</script>
********NetSuite recommended method listed below*********
Capture the IP address of Lead records from the Web Store
Published 02/29/2012 07:19 AM | Updated 07/18/2012 10:39 AM | Answer Id: 21425
Capture the IP address of Lead records from the Web Store
This is a alternate solution to capture the IP address of Lead records the moment a new customer registers on the Web Store.
1. Create a Custom Entity Field:
a. Navigate to Setup > Customization > Entity Fields > New.
b. Name the field as Lead IP Address.
c. Set Type to Free-Form Text.
d. Set Store Value to True.
e. At the Applies to tab, check the Customer and the Web Site box.
f. At the Display tab, change the Display type to Normal.
g. Click Save.
2. Add the script to your Web Site Theme:
a. Navigate to Setup > Web Site > Set Up Website, Appearance tab.
b. Take note of the Web Site Theme
c. Navigate to Setup > Web Site > Themes
d. Edit the applied theme, click the Body Tab
e. Add the script in the Footer Template field
<script language="javascript" type="text/javascript">
document.getElementById("custentity10").setAttribute("value","<%=getCurrentAttribute('request','ipaddress')%>");
document.getElementById("custentity10_fs_lbl").style.display = "none";
document.getElementById("custentity10_fs").style.display = "none";
</script>
f. Click Save.
3. Go to the Web Store and register as a new customer. View the Lead record created and notice that the IP address is tracked under the Custom Tab > Lead IP address entity field.