Payroll Batch

This record is available only for SuitePeople U.S. Payroll customers. For more information, see SuitePeople Overview.

For help working with this record in the UI, see Creating a Payroll Batch.

The internal ID of this record is payrollbatch.

For information about scripting with this record in SuiteScript, see the following help topics:

See the SuiteScript Records Browser for all internal IDs associated with this record.

Note:

For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.

Supported Script Types

The payroll batch record is scriptable in both client and server SuiteScript.

Supported Functions

The payroll batch record is fully scriptable, which means that the record can be created, updated, copied, deleted and searched using SuiteScript.

Usage Notes

Be aware of the following:

Payroll Batch Status

Value

Description

Created

A

A new payroll batch has been created.

Calculated

B

A payroll batch has been calculated.

Edited

C

A payroll batch may have been calculated previously, or it is a newly created batch with some paychecks added or calculated.

About to Commit

D

Payroll is about to be committed.

Committed_At_Service

E

Payroll is committed for processing by payroll service, but some records need to be created in NetSuite.

Committed

F

Payroll is committed.

Completed

P

Payroll batch is completed.

Reversed

R

Payroll batch is reversed.

Error

X

Error occurred in payroll batch.

Code Samples

The following sample shows how to create a payroll batch and perform other basic tasks. It also includes how to add an employee to a payroll batch. For more information, see Payroll Batch Employee.

          require(["N/record"], function (record)
{
    var payrollbatch = record.create({
        type: 'payrollbatch',
        isDynamic: true
    });

    payrollbatch.setValue({
        fieldId: 'offcycle',
        value: false
    });

    payrollbatch.setValue({
        fieldId: 'payfrequency',
        value: '52'
    });

    payrollbatch.setValue({
        fieldId: 'periodending',
        value: new Date('6/15/2020')
    });

    var recId = payrollbatch.save();

    // Add employees to the payroll batch
    // In most cases, you would iterate through the addmorepayeesmachine to find the employees you would add to the batch

    var addemp = payrollbatch.load({
        type: 'payrollbatchaddemployees',
        id: id,
        defaultValues: 'true'
    });

    addemp.setSublistValue({
        sublistId: 'addmorepayeesmachine',
        fieldId: 'payemp',
        line: 1,
        value: 'T'
    });

    var recId2 = addemp.save();

    //Submit the record to be calculated
    payrollbatch = record.load({
        type: 'payrollbatch',
        id: id,
        defaultValues: 'false'
    });;

    var recId3 = payrollbatch.save();

    //Check the status of the record to ensure that calculating is complete before proceeding
    do {
        payrollbatch = record.load({
            type: 'payrollbatch',
            id: id,
            defaultValues: 'false'
        });

        status = payrollbatch.getValue({
            fieldId: 'status'
        });
    } while ( !(status ==='B' || status === 'E' || status ==='X') );

    //Set the flag to commit the payroll batch
    if (status ==='B') {
        payrollbatch.setValue({
            fieldId: 'commit',
            value: 'T'
        });
    }

    //Commit
    var recId3 = payrollbatch.save();

    do {
        payrollbatch = record.load({
            type: 'payrollbatch',
            id: id,
            defaultValues: 'false'
        });
        status = payrollbatch.getValue({
            fieldId: 'status'
        });
    } while ( !(status === 'F' || status === 'E' || status === 'X') );
}); 

        

Related Topics

General Notices