Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

How To: Script to Automate NetSuite Journal Entries

Accounting NetSuite Technical

Tags: , , , ,

This article is relevant if you want to automate the creation of NetSuite journal entries and you are comfortable with basic scripting concepts.

SuiteScript Code Example for Creating Journal Entries

The following code example is the bare minimum script pattern to get a journal entry into NetSuite through SuiteScript.  This code snippet should sit inside a SuiteScript User Event or Client script definition.  I recommend using the SuiteScript Records Browser to help you with the specific journal entry API field references.

var Trx = new custBizObject();  // our custom business object holding important data
var Config = new custConfigObject(); //our custom configuration object for our app
var memo = 'script to create journal entry';

var je = nlapiCreateRecord('journalentry');
je.setFieldValue('trandate', nlapiDateToString(nlapiStringToDate(Trx.StatusDate)));
je.setFieldValue('currency', Config.CurrencyReference);
je.setFieldValue('exchangerate', Trx.mExchRate);

//create the line items; first work control account
je.selectNewLineItem('line');
je.setCurrentLineItemValue('line', 'account', Config.APDefault);
je.setCurrentLineItemValue('line', 'debit', RoundNumber(Trx.mQtyGross, 2));
je.setCurrentLineItemValue('line', 'entity', entityID);
je.setCurrentLineItemValue('line', 'memo', memo);
je.commitLineItem('line');

// now work the bank account
je.selectNewLineItem('line');
je.setCurrentLineItemValue('line', 'account', Config.BankAccount);
je.setCurrentLineItemValue('line', 'credit', RoundNumber(Trx.mQtyGross, 2));
je.setCurrentLineItemValue('line', 'entity', Trx.Receipient);
je.setCurrentLineItemValue('line', 'memo', memo);
je.commitLineItem('line');

return nlapiSubmitRecord(je, true, false);		//return JE transaction number

Related Articles

  1. NetSuite Up Close: Custom GL Lines Plug-in to Reclass General Ledger Postings

Get Help

NetSuite is a great application development environment.  If you need help innovating on the platform, contact us.

Marty Zigman LinkedIn

Marty Zigman

Holding three official certifications, Marty is widely recognized as a top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. A former Deloitte & Touche CPA and technology executive with CTO roles, he brings over 35 years of leadership in ERP, CRM, and eCommerce business systems. Contact Marty to engage directly.

BiographyYouTubeLinkedInX (Twitter)

26 thoughts on “How To: Script to Automate NetSuite Journal Entries

  1. Thanks for this, Marty. I’ve noticed here and other places that people often use the
    nlapiDateToString(nlapiStringToDate(Trx.StatusDate)

    pattern when working with dates in SuiteScript. So I’m curious why that is. If I need a date and it’s already a date, why jump through the hoops? What’s the advantage?

    Reply
  2. hi sir,
    how to get particular date tranaction using filter search.
    ex- i want all invoices we are created 25 for every month.

    Reply
  3. hey sir i am a student. can i please get a sample code from you on how to code the journal entries and will also give its financial statement or income statement after i put my transaction. i will be glad if you reply sir. 🙁 you will be my life saver 🙁

    Reply
  4. hii
    can u help me out with suiteGL custom gl lines scripting.

    some sample codes

    i checked in netsuite helpcenter, i need something better than that

    Reply
  5. Hi Marty,
    Thanks for your helpful information.
    I am trying to update journal entry using Suite talk API it is giving error-:
    Journal Entries can have a maximum of 1000 lines

    Is there any way to update journal entry have more than 1000 rows
    Thanks,
    Hitesh Kumar.

    Reply
  6. Hi Marty,

    JE sub list is keyed or not keyed?

    I am trying to update a single line but getting error for line.line,but i am able to add new line.

    Thanks Hitesh,

    Reply
  7. Hi Marty.

    I am using the suite talk API with c#,and I get the the line number for every line but when i try to update particular line by providing the line number, I am getting the error.

    Thanks,
    Hitesh.

    Reply
  8. I like the basic script a lot. I see that it’s written with Suitescript 1. I have to do something similar today.

    Would you recommand to start with you script or redo it entirely with Suitescrip 2 ?

    Thanks
    Real

    Reply
  9. Hi Marty,

    I am trying to Create the Advance Intercompany journals using Suitescript 2.0 but it is throwing the error as Please enter value(s) for: Account even i am passing the account for Line level.

    But it is working when we use suitescript 1.0.

    Please help me on this.

    Reply
  10. Was this resolved? I am having the same issue.
    Trying to create the Advance Intercompany journals using Suitescript 2.1 but it is throwing the error as Please enter value(s) for: Account even i am passing the account for Line level.

    Reply
  11. Found out the answer to my question Feb.27 2024. This error was completely misleading. The issue was that on the sublist line field id I was coding -‘subsidiary’, when it fact the field name for AICJ is fieldId: ‘linesubsidiary’. The Records Browser confirmed this, and as soon as I changed the name, bingo, everything worked. By the way, NetSuite AICJ sample code uses ‘subsidiary’ for the field id…. just needed to point that out. Hope this helps someone struggling with this.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *