NetSuite’s SuiteTalk web service enables you to automate and schedule the import of your data from staged files as a transaction in NetSuite.  In this example, I am going to demonstrate a sample routine that will import ACH payment data from an external ACH service into NetSuite as payments.  However, before importing, it is critical that I ensure that I do not duplicate records, which is what I’m going to focus on in this article.  You can achieve this by performing a duplicate check against a custom body field.

SuiteTalk Code Sample

private  Boolean FindDuplicatePayment(string pyt_identifier)

{

    SearchResult transactionSBR;

    List<SearchStringCustomField> oCustomSearchStringList =new List<SearchStringCustomField>();

    SearchStringCustomField custbody_achIdentifier =  newSearchStringCustomField();

    custbody_achIdentifier.scriptId=”custbody_pyt_ach_identifier”;  // id of customField    custbody_achIdentifier.searchValue = pyt_identifier; //value to check

    custbody_achIdentifier.operatorSpecified = true;

    custbody_achIdentifier.@operator =SearchStringFieldOperator.@is;

    oCustomSearchStringList.Add(custbody_achIdentifier);

    TransactionSearchAdvanced transactionSA = newTransactionSearchAdvanced()

    {

        //Below is the saved search that is defined in Netsuite already.

        savedSearchScriptId =”customsearch_check_pyt_identifier”,

        criteria = new TransactionSearch()

        {

            basic = new TransactionSearchBasic()

            {

                customFieldList =  oCustomSearchStringList.ToArray(),

            }

        }

    };

    transactionSBR = netSuite.service.search(transactionSA);

    if (transactionSBR.status.isSuccess)

    {

        if (transactionSBR.searchRowList.Length != 0 && transactionSBR.searchRowList != null)

        {

            Console.WriteLine(String.Format(“Identifier found.. This record will not be imported.{0} “, pyt_identifier));

            return true;

        }

        return false;

    }

    return false;

}

Summary

Below is brief explanation of the above code sample.

  • pyt_identifier is the value to search within NetSuite
  • The identifier is a custom body field in NetSuite and must be scoped as SearchStringCustomField
  • The saved search in the example is customsearch_check_pyt_identifier which is already created in NetSuite as a saved search
  • oCustomSearchStringList works as a filter to the saved search by checking pyt_identifier value
  • transactionSBR will store saved search results and in this case I am just using the record count (length) to determine duplication

I hope this is useful.  If you’re looking for help extending, integrating and customizing NetSuite, please feel free to contact the MIBAR team – we’re here to help!

Until next time, happy coding!

Additional NetSuite Resources

Why You’ll Love NetSuite’s Business Intelligence Dashboards

Creating Filtered Dropdown Lists in a Custom Field in NetSuite

Update Hidden Subsidiary Sublists in NetSuite

6 Tips for NetSuite Advanced PDF Templates

Wait! Before You GoWould you like to talk to a business software expert to answer your questions?

When you schedule a free consultation with MIBAR, you will experience a one-on-one conversation with a business technology expert who is passionate about understanding your unique needs or issues. Schedule a free consultation today at the link below or give us a call at (212) 869-9300.

Learn More
Open for Business – The Path to Recovery

This webinar is focused on helping leaders plan for the future and adapt their business model as the economy reopens.

Join MIBAR as we host guest panelist Gary Bettan, President of Broadfield Distributing Inc., Founder and President of Videoguys, and a digital transformation expert who has helped startups and mid-market leaders future-proof their business in an ever-changing competitive landscape.