Netsuite allows you to create a Custom Record to store table of data collected from an external form. For example, you may create an email opt-in form on your external website, and submit the form to Netsuite. The submitted data will be processed by a Suitelet, and stored as a Custom Record in Netsuite. The form must be able to process concurrent users, and hence Suitelet is favored over SuiteTalk (Web Service). NetSuite web service has a concurrency problem, so SuiteTalk should not be used in this type of scenarios.
Let's assume that we are going to collect Name and Email address of a user on the opt-in form, and they will be stored in the "Optin" Custom Record. The form elements ("name" and "email") have to be mapped as custom fields in the "Optin" custom record.
1. Login to Netsuite as an administrator.
2. Create a Custom Record by choosing Setup -> Customization -> Record Types -> New.
Name: Optin ID: customrecord_optin
3. Create two custom fields for "Optin" custom record.
Name: Name ID: custrecord_optin_name Type: Free-Form Text Store Value = checked Name: Email ID: custrecord_optin_email Type: Email Address Store Value = checked
Once a custom record and custom fields have been created in the NetSuite, form data can be posted to Netsuite for insertion.
Searching on Custom Records
Now that we have a custom record created, we will discuss how to search for a custom field within a custom record. Here is an example on how to search an email address from the custom record we created above.
var email = "[email protected]"; var filters = new Array(); filters[0] = new nlobjSearchFilter('custrecord_optin_email', null, 'is', email); var columns = new Array(); columns[0] = new nlobjSearchColumn( 'custrecord_optin_name' ); var results = nlapiSearchRecord( 'customrecord_optin', null, filters, columns ); if (results != null) { // We are expecting one record if any has been retrieved. var result = results[0]; var name = result.getValue('custrecord_optin_name'); }
Comments
Custom Record search in SuiteScript cause "invalid column" error
Follow the example above, but I'm getting an invalid column error:
Error: SSS_INVALID_SRCH_COL
An nlobjSearchColumn contains an invalid column, or is not in proper syntax: custrecord_optin_email.
Re: Custom Record search in SuiteScript cause "invalid column"
The field's default level for Search/Reporting should be changed to "Edit". The "Run" level won't allow search execution.
Add new comment