Monday 5 December 2016

Dynamically Determine the Netsuite Field Type in an Existing Object

Sometimes back I was ran into  an issue in one of my project where we had a requirement to dynamically display the fields to User in a customized UI and the field has to be displayed according to the definition of Netsuite field types. For example say Today someone has added a  new field into the object and marked it as mandatory then irrespective of the type of the filed which has been created it has to be reflected on the customized UI page to the user and should let the user identify the field as mandatory while creating a record.

So below is the script which would dynamically help to determine the mandatory fields in an Object.



function getFields(datain) {
    var record = nlapiCreateRecord ( datain.recordtype );
    var fields = record.getAllFields();
    var requiredFields = {};
    fields.forEach(function(fieldName){
        var field = record.getField(fieldName);
        if(field.mandatory === true) {
            var id = field.getName();
            var field_details = {}
            field_details['Type'] =  field.getType();
            field_details['Label'] =  field.getLabel();
            if(field.getType() == 'select' || field.getType() == 'multiselect') {
                var Options = field.getSelectOptions();
                var selectOptions = {};
                for(var i in Options) {
                    var opt_id = Options[i].getId();
                    selectOptions[opt_id] = Options[i].getText()
                }
                field_details['Options'] =  selectOptions;
            }
            requiredFields[id]=field_details;
        }
    });
    return requiredFields;
 }​

Sunday 20 November 2016

Netsuite Procure To Pay Process

Procure to Pay

NetSuite streamlines the entire procure to pay process, with employee self-service, approval, management, matching, receiving, payments, and through various reportings. Ensuring a seamless linkage across employee, procurement and finance processes.  





  • PO Entry : NetSuite web base self service makes easy for employees to manage expenses time tracking purchase requisitions and more and just a few clicks employees can create purchase orders. 
  • Approval : NetSuite insurance that purchase orders are in complaint with corporate policy’s and are sent to the real time right to manager for approval. Mangers can review the detail PO approve or rejected and NetSuite will rap the PO appropriately based on the work flow. 
  • Item Receipt : On receipt on the bill NetSuite makes it easy to locate and manage purchase order that was previously created, approved, and received. 
  • Matching : When orders are received without a PA belt, NetSuite minimizes the risk of error by automatically populating the bill screen with data from centralize customer records that could be matched against for accuracy.  
  • AP Bill Approval : Once the AP billing information was been added NetSuite powerful work flow engine makes it easy to set up a approval requirements that eliminates unnecessary spending while enforcing company policy’s and then raps bills to the appropriate approvals. 
  • AP Bill Aging : Approve bills are automatically posted to the AP sub ledgers and general ledger where finance managers can efficiently drill in to reliable aging details provided by Netsuits complete purchasing audit trail. 
  • Bill Payments : To help reduce cost and maintain strong vendors’ relationships NetSuite lets manager set up alerts that insurance bills by their due dates and within discount allowances. NetSuite provides a clear perspective on spending from the purchase order all the way through to vendor record where contact information, schedule activities, message history, and all associated transaction with the vendor are available in one convenient location.
  • Summary : NetSuite Integrates employee, procurement and finance processes and provide complete transparency and control over the entire purchasing process. From PO entry and approval through to receiving to accounts payable. NetSuite ensures a stream line and more effective process while ensuring checks and balances and visibility throughout the process.
  • Tuesday 27 September 2016

    Publish Search in Site Builder site

    NetSuite customer support assisted me on this and showed me how to get it to work. The steps are:
    1.Check "Display in Web Store" on item records
    2.Change the layout of the Published Saved search to "Standard Dense List Layout"
    3.If needed customize the layout: Setup > Site Builder > Layouts

    Thanks to NetSuite for the assistance here!​​ :)

    Monday 19 September 2016

    Restricting item to Purchase only

    The scenario was basically where some of the Inventory Item were needed to be restricted to the Purchase Order only and should not appear on the Sales Order.​


    To solve this problem you can add an item filter on a custom sales order form. You need to create a saved search first and then add the search as an item filter.

    Please follow the steps below:
    A. Create a saved item search
    1. Navigate to Lists > Search > Saved Searches > New > Item
    2. Under Criteria subtab, add the required filters.
    3. Under Results subtab, add or remove fields depending on your preference.
    4. Enter a Search Title.
    5. Hit Save.

    B. Add the item filter on custom sales order form
    1. Open the sales order form to be customized.
    2. Navigate to Screen fields > Columns.
    3. Under Item Filter dropdown, select the item saved search you want to determine which items are shown in the Items dropdown on this transaction form.
    4. Hit Save.
    ​​​

    You can also consider using Non-Inventory for Purchase if you don't really intend to sell them.

    If you are creating new inventory items, under the Accounting tab, just leave the Income Account blank to prevent the items from showing up on sales transactions.

    Saturday 17 September 2016

    Common Netsuite Interview Questions

    What is a Lead and how they are captured in Netsuite ?

    In Accounting a Lead is nothing but an identification of a person or entity that has the interest and authority to purchase a product or service. In Netsuite "Lead" is a standard record object which has several predefined fields to capture the Lead information. 

    What is Lead Generation Process ?

    Lead Generation is the initiation of consumer interest or inquiry into products or services of a business.

    How Leads are converted in Netsuite ?
                               Or
    What is the Lead conversion process in Netsuite ?

    There are two ways a lead can be converted to a prospect or customer in NetSuite:

    If an opportunity, estimate, or sales transaction is entered for the lead, it is automatically converted according to the default statuses you have set up at Setup – Sales – Preferences – Sales Preferences.

    If you use the Lead Conversion feature, you can click the Convert button on the lead record. Converting a lead in this way gives you additional options on which records are created or updated. This is commonly used flow by business-to-consumer, or B2C, sales organizations.

    How does Procure to pay Process works in Netsuite ?

    Netsuite Procure to Pay Process involves the following steps :

    Purchase Order Entry => Purchase Order Approval => Receiving => Matching => Bill Approval


    What is Lead to Cash Process in Netsuite ?

    Lead => Opportunity => Quote => Order => Fulfill => Invoice => Billing

    What is Purchase Order Cycle in Netsuite ?


    PR/PO => Recieving => Update Inventory => Enter Bills => Bills Payment => Accounting Posting

    What is Suitescript ?


    SuiteScript is a JavaScript-based API that gives developers the ability to extend NetSuite beyond the capabilities provided through SuiteBuilder point-and-click customization.
    How do I run a script in NetSuite?
    The overall process for getting a script to run in NetSuite is fairly basic. This process includes:
    1.    Creating a JavaScript file for your script.
    2.    Uploading the file into NetSuite.
    3.    Creating a NetSuite “Script” record for your script.
    4.     Defining script runtime options on a NetSuite Script Deployment page.


    What are the different types of Scripts in Netsuite and How they are used ?


    ·         User Event Scripts: User Event scripts are triggered when users work with records and data changes in NetSuite as they create, open, update, or save records. User Event scripts are useful for customizing the workflow and association between your NetSuite entry forms. These scripts can also be used for doing additional processing before records are entered or for validating entries based on other data in the system.
    ·         Suitelets: Suitelets enable the creation of dynamic web content. Suitelets can be used to implement custom front and backends. Through API support for scripting forms and lists, these Suitelets can also be used to build NetSuite-looking pages. NetSuite tasklinks can be created to launch a Suitelet. These tasklinks can be used to customize existing centers.
    ·         RESTlets: RESTlets are server-side scripts that can be used to define custom, RESTful integrations to NetSuite. RESTlets follow the principles of the REST architectural style and use HTTP verbs, HTTP headers, HTTP status codes, URLs, and standard data formats. They operate in a request-response model, and an HTTP request to a system-generated URL invokes each RESTlet.
    ·         Scheduled Scripts: Scheduled scripts are executed on-demand in real-time or via a user-configurable schedule. Scheduled scripts are useful for batch processing of records.
    ·         Client Scripts: Client scripts are executed on the client. These scripts can be attached to and run on individual forms, or they can be deployed globally and executed on entity and transaction record types. Global client scripts enable centralized management of scripts that can be applied to an entire record type.
    ·         Portlet Scripts: Portlet scripts are used to create custom dashboard portlets. For example, you can use SuiteScript to create a portlet that is populated on-the-fly with company messages based on data within the system.
    ·         Mass Update Scripts: Mass update scripts allows you to programmatically perform custom mass updates to update fields that are not available through general mass updates. You can also use action scripts to run complex calculations, as defined in your script, across many records.
    ·         Workflow Action Scripts: Workflow action scripts allow you to create custom actions that are defined on a record in a workflow.
    ·         Bundle Installation Scripts: Bundle installation scripts fire triggers that execute as part of bundle installation, update, or uninstall. Trigger execution can occur either before install, after install, before update, after update, or before uninstall. These triggers automatically complete required setup, configuration, and data management tasks for the bundle.

    Common Netsuite Interview Questions II





    Set Up Third Party SMTP Server on NetSuite

    From version 2014 release 2 onwards, the feature to setup third party SMTP becomes available in NetSuite. This enables the user to set up a third party SMTP servers for sending bulk corporate email. It will enable the use of the user’s infrastructure to maintain and control the over all aspects of their outgoing bulk email communication.


    1. Navigate to Setup > Company > SMTP Servers
     
    2. Click New SMTP Server
     
    3. Fill up all the required fields:
     
    • Display Name – enter a descriptive name that will identify the server
      Hostname – enter the exact SMTP domain address e.g. bulk.smtp.netsuite.com
      Encryption – Select which encryption method to use to communicate between NetSuite and the mail server
      SSL : This is used to provide a way to encrypt a communication channel between two computers (e.g. user's computer and NetSuite server).
      STARTTLS : is a way to take an existing insecure connection and upgrade it to a secure connection using SSL
      Username – enter your email address
      Password – enter password for your email address
      Validation Token for Bulk eMail – enter the generated value that will be sent to provider’s postmaster
      4. Click Save.

      In order to use the new SMTP server user must set it as the preferred SMTP Server. Go back to email preferences and select the new server.
      1. Navigate to Setup > Company > Email Preferences > SMTP Server Settings
     
    2. On the dropdown, select the newly created SMTP Server
     
    3. Click Save​

    Display ‘Open Customer Deposits’ on Sales Orders

    By default, information about 'Open Customer Deposits' is not available on Sales Orders on fields or sublists. Users can create a saved search and make it available as a sub list to the said form.
    To create a saved search for Open Customer Deposits, please follow these steps:
    1.  Login as Administrator.
    2.  Navigate to Lists > Search > Saved Search > New.
    3.  Select Transaction.
    4.  Enter your desired search title (e.g. Open Customer Deposit).
    5. Mark the Public checkbox.
    6.  Under Criteria > Standard sub tab:
    Type = is Customer Deposit
    Main Line = is true
    Status = is any of Customer Deposit:Deposited, Customer Deposit: Not Deposited
    7.  Under the Results tab, Add or Remove field/s that you want to show.
    8.  Under Available Filters:
    Filter = Name
    Show in Footer = Yes
    9.  Click Save.
    To display it on a sublist:
    1.  Navigate to Customization > Forms > Sublists.
    2.  Under Transactions, select the Name or Title of the search that you created.
    3.  Enter your desired Label name (e.g. Open Customer Deposit).
    4.  Under the Tab column, select the specific tab from the transaction where you want to display it (e.g. Accounting).
    5.  Put a checkmark for the Sale column.
    6. Under Field, select a field that is common between the Sales Order and the Customer Deposit (i.e. Customer).

    7.  Click Save.​

    Sales Order Report with Columns Based on Due Dates from Alternate Date Ranges

    To create a Sales report which displays the total amount and columns to display due dates during alternate date ranges, a user can create the following Saved search:


    1. Navigate to Reports > Saved Searches > All Saved Searches > New

    2. Click on Transaction link

    3. Under Criteria tab > Standard subtab
         Type = Invoice
         Main Line = True
         Due Date = Not Before Today

    4. Under the Results tab > Columns subtab


    Field
    Formula
    Custom Label
    Number
    Name
    Amount (Transaction Total)
    Formula (Numeric)
    CASE WHEN {duedate}-{today} BETWEEN 0.01 AND 3 AND (to_char({duedate}, 'MM'))-(to_char({today}, 'MM')) = 0 then {duedate} ELSE null END
    This Month - Upto 3 Days from Today
    Formula (Numeric)
    CASE WHEN {duedate}-{today} BETWEEN 4 AND 7 AND (to_char({duedate}, 'MM'))-(to_char({today}, 'MM')) = 0 then {duedate} ELSE null END
    This Month - Days 4 -7 from Today
    Formula (Numeric)
    CASE WHEN {duedate}-{today} > 8 AND (to_char({duedate}, 'MM'))-(to_char({today}, 'MM')) = 0 AND (to_char({duedate}, 'YYYY'))-(to_char({today}, 'YYYY')) = 0 then {duedate}   ELSE null END
    This Month - Over 8 Days from Today
    Formula (Numeric)
    CASE WHEN (to_char({duedate}, 'MM'))-(to_char({today}, 'MM')) = 1 AND (to_char({duedate}, 'YYYY'))-(to_char({today}, 'YYYY')) = 0 then {duedate} else null END
    Next Month
    Formula (Numeric)
    CASE WHEN (to_char({duedate}, 'MM'))-(to_char({today}, 'MM')) <> 0 then {duedate} else null END
    2 Months and Onwards

    5. Under the Available Filters tab:
        Filter = Status > Show in Filter Region = Yes

    6. Rename the Search Title

    7. Hit Save & Run​


    Sunday 28 August 2016

    Printing a Sales Order

    To print a single sales order:
    1.     Go to Transactions > Sales > Enter Sales Orders (Administrator).
    2.     On the Sales Order page, complete the information as appropriate.
    3.     Click Save & Print.
    NetSuite opens the printout for your sales order in an Adobe application document.
    4.     Click the printer button in the Adobe application frame.
    5.     If you wish to print multiple copies, specify the number on the print message that appears.
    6.     Click OK.
    You can also print sales orders by going to Transactions > Sales > Enter Sales Orders > List (Administrator) . On the Sales Orders page, click Print next to the sales order you want to print.
    If you enter multiple sales orders before printing, you can print all the sales orders at once. Check the To Be Printed box on each transaction you enter.
    To print multiple sales orders:
    1.     Go to Transactions > Management > Print Checks and Forms (Administrator).
    2.     On the Print Checks and Forms page, click Sales Orders.
    3.     In the Form field, choose the transaction form you want to use to print these orders.
    4.     Check the Allow Reprinting box to be able to reprint previously printed transactions.
    When you check this box, all documents appear at the bottom of the page in segments.
    5.     Check the box in the Print column by each sales order you want to print.
    6.     Click Print.
    If you have not enabled the Download PDF Files preference on the Set Preferences page, a preview of your sales orders pops up in the default Adobe application.
    If you have enabled the Download PDF Files preference, you must first save your sales orders and then open them with the Adobe application.
    7.     Click the printer button in the Adobe application frame.
    8.     If you want to print multiple copies, specify the number on the print message that appears.
    9.     Click OK.​


    Saturday 27 August 2016

    Create a Standard Netsuite Record Using Restlet API

    Create a RESTlet with the following piece of code.

    // Create a standard NetSuite record
    function createRecord(datain)
    {
        var err = new Object();
       
        // Validate if mandatory record type is set in the request
        if (!datain.recordtype)
        {
            err.status = "failed";
            err.message= "missing recordtype";
            return err;
        }
       
        var record = nlapiCreateRecord(datain.recordtype);
       
        for (var fieldname in datain)
        {
         if (datain.hasOwnProperty(fieldname))
         {
             if (fieldname != 'recordtype' && fieldname != 'id')
             {
                 var value = datain[fieldname];
                 // ignore other type of parameters​
                 if (value && typeof value != 'object') 
                 {
                     record.setFieldValue(fieldname, value);
                 }
             }
         }
        }
        var recordId = nlapiSubmitRecord(record);
        nlapiLogExecution('DEBUG','id='+recordId);
       
        // returns the created record in JSON format​
         var nlobj = nlapiLoadRecord(datain.recordtype,recordId);
        return nlobj;
    }​
    

     Step 1 : Upload the script
















    Step2 : Deploy the script

















































    Remember to put the status to released if you want to access the end point externally. If you're in test mode then select "Testing" as the status. In "Testing mode" your API can't be accessed  outside. You also has to select the "Role" and "Employee" in order to give them to access your API.

    Step 3 : Endpoint Generation








    Step4 : How to access this API

        url = 'https://rest.na1.netsuite.com/app/site/hosting/restlet.nl?script=166&deploy=2'
        authorization = 'NLAuth nlauth_account=111111,nlauth_email=email@email.com,nlauth_signature=password,nlauth_role=correctRole' 
        req = urllib.request.Request(url)
        req.add_header('Authorization', authorization)
        req.add_header('Content-Type','application/xml')
        req.add_header('Accept','application/json')  
        // call the end point with appropriate playload with above headers in a POST call