Budget Machine
A budget machine is a matrix machine containing amounts for budget categories and calendar months. Exposed budget machine macros implement logic of the header buttons and support a manipulation with the content of the machine. You can find budget machines in the Project, Project Task, and Project template records. Each record contains cost budget (cbudget) and billing budget (bbudget) machines. The record currently supports the clearBudgetAmounts, distributeBudgetTotalAmount, selectAllBudgetLines, setBudgetAmountsToCalculated, and unselectAllBudgetLines macros.
For information about SuiteScript 2.x record macros, see the following help topics:
clearBudgetAmounts
Corresponding UI Buttons |
Clear Values |
Macro Description |
Sets amounts to empty value for all selected lines. |
Returns |
This macro does not return any value. |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2021.1 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The unselectAllBudgetLines macro also requires the following additional parameter.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
requisites.params.sublistId |
string |
required |
Identifies a budget sublist (cbudget|bbudget) |
2021.1 |
Sample Return Objects
The following sample shows how to select all lines in Cost Budget and how to reset all amounts in Cost Budget.
require(['N/currentRecord'], function(currentRecord) {
var project = currentRecord.get();
// reset all amounts in Cost Budget
project.executeMacro({
id: 'clearBudgetAmounts',
params: {
sublistId: 'cbudget'
}
});
});
distributeBudgetTotalAmount
Corresponding UI Buttons |
Distribute Total |
Macro Description |
Splits a total amount into all calendar months for all selected lines. |
Returns |
This macro does not return any value. |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2021.1 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The unselectAllBudgetLines macro also requires the following additional parameter.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
requisites.params.sublistId |
string |
required |
Identifies a budget sublist (cbudget|bbudget) |
2021.1 |
Sample Return Objects
The following sample shows how to use calculated values or distribute total amount.
require(['N/currentRecord'], function(currentRecord) {
var project = currentRecord.get();
// use calculated values / distribute total amount
project.executeMacro({
id: 'setBudgetAmountsToCalculated' // 'distributeBudgetTotalAmount'
params: {
sublistId: 'cbudget'
}
});
});
selectAllBudgetLines
Corresponding UI Buttons |
Mark All |
Macro Description |
Checks all enabled boxes in the Select column. |
Returns |
This macro does not return any value. |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2021.1 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The selectAllBudgetLines macro also requires the following additional parameter.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
requisites.params.sublistId |
string |
required |
Identifies a budget sublist (cbudget|bbudget) |
2021.1 |
Sample Return Objects
The following sample shows how to select all lines in Cost Budget.
require(['N/currentRecord'], function(currentRecord) {
var project = currentRecord.get();
// select all lines in Cost Budget
project.executeMacro({
id: 'selectAllBudgetLines',
params: {
sublistId: 'cbudget'
}
});
});
setBudgetAmountsToCalculated
Corresponding UI Buttons |
Set to Calculated |
Macro Description |
Replaces amounts with calculated values for all selected lines. |
Returns |
This macro does not return any value. |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2021.1 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The unselectAllBudgetLines macro also requires the following additional parameter.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
requisites.params.sublistId |
string |
required |
Identifies a budget sublist (cbudget|bbudget) |
2021.1 |
Sample Return Objects
The following sample shows how to use calculated values or distribute total amount.
require(['N/currentRecord'], function(currentRecord) {
var project = currentRecord.get();
// use calculated values / distribute total amount
project.executeMacro({
id: 'setBudgetAmountsToCalculated' // 'distributeBudgetTotalAmount'
params: {
sublistId: 'cbudget'
}
});
});
unselectAllBudgetLines
Corresponding UI Buttons |
Unmark All |
Macro Description |
Clears all enabled boxes in the Select column. |
Returns |
This macro does not return any value. |
Supported Script Types |
Client and server scripts For additional information, see SuiteScript 2.x Script Types. |
Since |
2021.1 |
Parameters
See Record.executeMacro(options) for details about parameters required for the execution of any macro. The unselectAllBudgetLines macro also requires the following additional parameter.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
requisites.params.sublistId |
string |
required |
Identifies a budget sublist (cbudget|bbudget) |
2021.1 |
Sample Return Objects
The following sample shows how to unselect all lines in Cost Budget and how to select some lines.
require(['N/currentRecord'], function(currentRecord) {
var project = currentRecord.get();
// unselect all lines in Cost Budget
project.executeMacro({
id: 'unselectAllBudgetLines',
params: {
sublistId: 'cbudget'
}
});
// select some lines
for (var line = 0; line < project.getLineCount({sublistId: 'cbudget'}); line++) {
if (...) {
project.setSublistValue({
sublistId: 'cbudget',
fieldId: 'selectline',
line: line,
value: true
});
}
}