Project Charge Rule Record Macros

The charge rule record type currently supports the copyResources macro.

For help working with this record in the UI, see Understanding Charge Rules.

For information about SuiteScript 2.x record macros, see the following help topics:

copyResources

Corresponding UI Button

Copy Resources from Tasks

Macro Description

As part of a time—based charge rule defined on a project, copies to the charge rule all project resources that have a project task assignment. This includes resources that have actual time for the project or for one of its project tasks.

If the Resource Allocations feature is enabled, this also includes resources that have a resource allocation for a project task.

If the Allow Allocated Resources to Enter Time to All Tasks project preference is enabled, this also includes resources that have a resource allocation for the project.

Returns

{notifications:[], response:{}}

Supported Script Types

Client and server scripts

For additional information, see SuiteScript 2.x Script Types.

Since

2018.1

Parameters

See Record.executeMacro(options) for details about parameters required for the execution of any macro. The copyResources macro does not support any additional parameters.

Charge Rule copyResources Macro Syntax

            // On a current record (when a time-based charge rule is opened in a browser)
require(['N/currentRecord'], function(current) {
    var rec = current.get();
    rec.executeMacro({
        'id': 'copyResources'
    });
}); 

          
            //Creating new time-based charge rule on an existing project, and executing the macro on it
require(['N/record'], function(record) {
    var chargeRule = record.create({
        type: record.Type.CHARGE_RULE,
        isDynamic: true,
        defaultValues: {
            'chargeruletype': 'TIMEBASED', 
            'project': '968' 
        }
    });
    chargeRule.setValue({
        fieldId: 'name',
        value: 'my time-based charge rule'
    });
    chargeRule.setValue({
        fieldId: 'ratesourcetype',
        value: 'RESOURCES'
    });
    chargeRule.executeMacro({
        id: 'copyResources'
    });
    chargeRule.save();
}); 

          

Related Topics

General Notices