Sunday, October 7, 2018

How to get the current or all Posting Period via Script?

Question:
 
User needs to get the current or all Posting Period via Script. This will be used to a business process that they have.
 

Answer:
function getCurrentPostingPeriod() {
      // Get current Posting Period
      var postingTransaction = nlapiCreateRecord('invoice'); //Transaction should be a posting transaction
      var currentPostingPeriod = postingTransaction.getFieldValue('postingperiod');

     // Get all Posting Period
    var postingTransaction2 = nlapiCreateRecord('invoice'); //Transaction should be a posting transaction
    var fldPostingPeriod = postingTransaction2.getField('postingperiod');
    var fldPostingPeriodArr = fldPostingPeriod.getSelectOptions();  
}
 
Notes:
1. The above function illustrates how to get the current or all Posting Periods.
 
2. User can integrate the above logic to cater for their business process.
 
3. Accounting Periods are currently not scriptable.

No comments:

Post a Comment