Sunday, 9 June 2019

How to Create a Journal Entry in NS using SuiteScript 2.0 ?

What is a journal ?

A journal is a detailed account that records all the financial transactions of a business, to be used for future reconciling of and transfer to other official accounting records, such as the general ledger. 

A journal states the date of a transaction, which accounts were affected, and the amounts, usually in a double-entry bookkeeping method.

How can we create a Journal entry in NS? (Considering Classic Center)
Go to Transactions -> Financial -> Make Journal Entries (click on it).
We must enter credit and debit lines for balancing.
If any situation comes like, to create an automated JE using suiteScript 2.0, below is the way we can do:

var journal = record.create({
    type : record.Type.JOURNAL_ENTRY, (<< you can search for the Enum value in SuiteScript2.0 API provided by NS>>)
    isDynamic : true
    });
   
//set the values in the required fields in JE main section
    journal.setValue('subsidiary',subsidiary);
    journal.setValue('trandate',date);
    journal.setValue('memo',"Creating journal")
   
// Credit line
    journal.selectNewLine('line');
//Set the value for the field in the currently selected line.
    journal.setCurrentSublistValue('line','account',Acct);
    journal.setCurrentSublistValue('line','credit', Amt);
    journal.setCurrentSublistValue('line','memo',"Account Balancing");
    //Commits the currently selected line on a sublist.
journal.commitLine('line');
   
// Debit Line
    journal.selectNewLine('line');
//Set the value for the field in the currently selected line.
    journal.setCurrentSublistValue('line','account',depAcct);
    journal.setCurrentSublistValue('line','debit', checkAmt);
    journal.setCurrentSublistValue('line','memo',"Account Balancing");
//Commits the currently selected line on a sublist.
    journal.commitLine('line');
    //save the record.
    journal.save();

In the above code, we are trying to create a journal entry in dynamic mode.

This should work, in case please let me know.

Thanks

5 comments:

  1. above code doesn't work produces error for me

    {'error': {'code': 'INVALID_FLD_VALUE', 'message': '{"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value 887 for the following field: account","stack":["anonymous(N/serverRecordService)","doPost(/SuiteScripts/restlets.js:77)"],"cause":{"type":"internal error","code":"INVALID_FLD_VALUE","details":"You have entered an Invalid Field Value 887 for the following field: account","userEvent":null,"stackTrace":["anonymous(N/serverRecordService)","doPost(/SuiteScripts/restlets.js:77)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}'}}

    ReplyDelete
  2. @jace Sunga it's telling you the value for account is not acceptable

    ReplyDelete
    Replies
    1. Jerry can you exact value of depAcct and Acct please? I m getting this error

      "message": "{\"type\":\"error.SuiteScriptError\",\"name\":\"INVALID_FLD_VALUE\",\"message\":\"You have entered an Invalid Field Value 6 for the following field: account\",\"stack\":[\"anonymous(N/serverRecordService)\",\"post(/SuiteScripts/ssv2/journal_restlet.js:73)\"],\"cause\":{\"type\":\"internal error\",\"code\":\"INVALID_FLD_VALUE\",\"details\":\"You have entered an Invalid Field Value 6 for the following field: account\",\"userEvent\":null,\"stackTrace\":[\"anonymous(N/serverRecordService)\",\"post(/SuiteScripts/ssv2/journal_restlet.js:73)\"],\"notifyOff\":false},\"id\":\"\",\"notifyOff\":false,\"userFacing\":false}"

      Delete
  3. Thanks and that i have a tremendous offer you: What To Expect When Renovating A House custom home remodeling

    ReplyDelete