Expense Report Restriction

Script type is User event script .The main entry point used here is “before Load”.

beforeLoad(scriptContext):

Defines the function that is executed before a record is loaded; that is, whenever a read operation
occurs on a record, and prior to returning the record or page.These operations include navigating to a record in the UI, reading a record in SOAP web services,and loading a record. The beforeLoad event cannot be used to source standard records. Use the pageInit client script for this purpose.

Notes:
■ beforeLoad user events cannot be triggered when you load/access an online form.
■ Data cannot be manipulated for records that are loaded in beforeLoad scripts. If you attempt to
update a record loaded in beforeLoad, the logic is ignored.
■ Data can be manipulated for records created in beforeLoad user events.
■ Attaching a child custom record to its parent or detaching a child custom record from its parent
triggers an edit event.

This event can be used with the following context.UserEventType:
■ create
■ edit
■ view
■ copy
■ print
■ email
■ quick view

Typical use cases for beforeLoad

  • Modify the UI form before the user sees it
  • Set default field values
  • Data pre-processing

Sample program for Load a message on beforeLoad

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(["N/log"], function (log) {
    function beforeLoad(context) {
        log.debug({
            "title": "Before Load",
            "details": "type=" + context.type
        });
    }

    return {
        "beforeLoad": beforeLoad
    };
});

Expense report

Expense report navigation is

Transaction ->Employee->Enter expense report

Parameters used in the user event is

scriptContext.form :: The current form.

scriptContext.newRecord :: The new record.

scriptContext.request ::

The HTTP request information sent by the browser. If the event was triggered by a server action, this value is not
present.

scriptContext.type:: The type of operation invoked by the event (the trigger type). The type can be any of the possible values for the context.UserEventType enum.
This parameter allows the script to branch out to different logic depending on the operation type. For example,
a script with deltree logic that deletes a record and all of its child records.

If you have an Employee Center based role, you can access the expense report forms by going to your home page, and then selecting the Enter Expense Reports link. If you do not have an Employee Center based role, you can also access Expense Reports by going to Transactions > Employees > Enter Expense Reports.

To create the Expense Category in NetSuite:

  1. Log in to NetSuite and navigate to Setup > Accounting > Expense Categories > New.
  2. In the Name field, enter the name of this expense category.
  3. In the Expense Account field, select the expense account for items charged to this category.

Leave a comment

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