Script
Script
(Java client)
As announced at Kinexions 2024, RapidResponse is being renamed Maestro.
Updates are in progress, but you might still see RapidResponse in places.
SU 2507
Kinaxis Confidential Information – for use by Kinaxis Inc. (together with its affiliates, “Kinaxis” or “we”) and
authorized customers and partners of Kinaxis only.
If you are a licensed user of the software product(s) addressed in this documentation, you may print, or
otherwise make available, a reasonable number of copies of the documentation for internal use in connection
with that software, provided that all Kinaxis copyright notices and legends are affixed to each reproduced copy.
The right to print, or otherwise make available, copies of the documentation is limited to the period during
which the applicable license for such software remains in full force and effect. If the license terminates for any
reason, it is your responsibility to certify in writing to Kinaxis upon request that all copies and partial copies of
the documentation have been returned to Kinaxis or destroyed.
All specifications, claims, features, representations, and/or comparisons provided are correct to the best of our
knowledge as of the date of publication, but are subject to change without notice. While we will always strive to
ensure our documentation is accurate and complete, this document may also contain errors and omissions of
which we are not aware.
THIS INFORMATION IS PROVIDED BY KINAXIS ON AN “AS IS” BASIS, WITHOUT ANY OTHER WARRANTIES OR
CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABLE
QUALITY, SATISFACTORY QUALITY, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THOSE
ARISING BY LAW, STATUTE, USAGE OF TRADE, COURSE OF DEALING OR OTHERWISE. YOU ASSUME THE
ENTIRE RISK AS TO THE RESULTS OF THE INFORMATION PROVIDED. WE SHALL HAVE NO LIABILITY TO YOU
OR ANY OTHER PERSON OR ENTITY FOR ANY INDIRECT, INCIDENTAL, SPECIAL, OR CONSEQUENTIAL
DAMAGES WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, LOSS OF REVENUE OR PROFIT, LOST OR
DAMAGED DATA OR OTHER COMMERCIAL OR ECONOMIC LOSS, EVEN IF WE HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES, OR THEY ARE FORESEEABLE. WE ARE ALSO NOT RESPONSIBLE FOR CLAIMS
BY A THIRD PARTY. OUR MAXIMUM AGGREGATE LIABILITY TO YOU AND THAT OF OUR DEALERS AND
SUPPLIERS SHALL NOT EXCEED THE COSTS PAID BY YOU TO PURCHASE THIS DOCUMENT. SOME
STATES/COUNTRIES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR
INCIDENTAL DAMAGES, SO THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU.
Copyright © 2011-2025 Kinaxis Inc. This document and its contents are the property of Kinaxis Inc. and are
protected by copyright and other intellectual property laws. Except as set out herein, this document may not be
reproduced or transmitted in any form (whether now known or hereinafter discovered or developed), in whole
or in part, without the express prior written consent of Kinaxis.
Trademark notice: This document includes certain trademarks, trade names and service marks which are
protected under applicable intellectual property laws and are the property of Kinaxis. Trademarks, including but
not limited to KINAXIS, KINAXIS MAESTRO, RAPIDRESPONSE and MPO, are the trademarks or registered
trademarks of Kinaxis Inc. and/or its affiliates, and the exclusive rights to such trademarks are expressly
reserved. Solely for convenience, Kinaxis’ trademarks (such as Kinaxis and Kinaxis Maestro) may appear without
the ® or ™ symbol, but such references are not intended to indicate, in any way, that we will not assert our
rights to these trademarks to the fullest extent under applicable law. Trademarks used in this document, other
than those belonging to Kinaxis, are the property of their respective owners.
Kinaxis Maestro contains technology that is protected under a global patent portfolio, including those patents
listed here: https://www.kinaxis.com/en/patents.
This document may include examples of fictitious companies, products, Web addresses, email addresses, and
people. No association with any real company, product, Web address, email address, or person is intended or
should be inferred.
Support: [email protected]
Web site: http://www.kinaxis.com
Contents
Contents 4
Part 1: Overview 18
CHAPTER 1: Welcome 20
CHAPTER 2: About Kinaxis 22
Customer Support 22
CHAPTER 3: Accessing help and documentation 24
Determining which help system or guide to use 27
Documentation conventions 29
Finding the content you need in HTML help 30
Your feedback 31
Help in resources 32
Other ways to learn about Maestro 36
CHAPTER 4: New and changed features 38
2025 scripting changes 39
2024 scripting changes 39
Glossary 576
Kinaxis enables our customers to improve and accelerate analysis and decision-making across
their supply chain operations.
We help leaders across multiple industries, including A&D, Automotive, High Tech, Industrial, and
Life Sciences to create a foundation for concurrent planning, continuous performance
monitoring, and coordinated responses to plan variances across multiple areas of the business.
Our single-product offering supports a full spectrum of supply chain related business processes,
including S&OP, supply planning, capacity planning, demand planning, inventory management,
MPS, and order fulfillment.
Our customers have immensely complex supply chain networks and volatile business
environments. Yet, they have been able to replace disparate planning and performance
management tools and realize significant operations performance breakthroughs in planning
cycles, supply chain response times, and decision accuracy. They can easily model varying supply
chain conditions to make both long-term and real-time demand and supply balancing decisions
quickly, collaboratively, and in line with the shared business objectives of multiple stakeholders.
For more information, visit www.kinaxis.com or the Kinaxis Knowledge Network at
http://knowledge.kinaxis.com/. Kinaxis trades on the Toronto Stock Exchange (TSX:KXS).
Customer Support
The Kinaxis Customer Support team understands demand and supply chain planning, monitoring,
and response, and is experienced in applying Kinaxis Maestro™ to real-world business scenarios.
Areas of expertise include:
If you are a key support contact, you can submit support cases. To submit a support case, sign in
to the Kinaxis Knowledge Network. You can also contact Kinaxis Customer Support by phoning
1-866-463-7877 or by sending a message to [email protected].
Go to https://knowledge.kinaxis.com and log in today. You can also access the Kinaxis
Knowledge Network from Maestro by clicking Kinaxis Knowledge Network on the Help menu.
The Maestro documentation set includes several different help systems and guides. Each deals
with a different area of knowledge.
Other resources are available to help you learn about the capabilities and features in Maestro.
These include an online community where you can view how-to videos and find advice, a mailing
list that you can use to keep up to date on supply chain news and upcoming events, and Maestro
training courses.
Note: The Help listed above (as well as Help supporting the Web and Mobile clients) can
be accessed by any user from the Documentation Center page on Knowledge Network.
Documentation formats
Most Maestro documentation resources are available in these formats:
l HTML help systems.
l PDF documents.
If you're looking at an HTML help system, you can open a PDF version of that help by clicking
Open a PDF version of the Help on the help page's navigation bar.
Title Description
Maestro User Guide (Java client) Basic reference and procedural information. It covers topics such
as viewing data, modifying data as part of simulation, solving
business problems, and customizing the user interface.
Procedures in this guide are for the Java client.
Maestro User Guide (Web client) Basic reference and procedural information. It covers topics such
as viewing data, modifying data as part of simulation, solving
business problems, and customizing the user interface.
Procedures in this guide are for the Web client.
Maestro Applications Guide (Java client) Information about the Maestro applications that support supply
chain planning processes across different functional areas.
Procedures in this guide are for the Java client.
Maestro Applications Guide (Web client) Information about the Maestro applications that support supply
chain planning processes across different functional areas.
Procedures in this guide are for the Web client.
Maestro Resource Authoring Guide (Java client) Information on creating and managing resources, such as
workbooks and filters. Detailed information about Maestro
Query language is also included. Procedures in this guide are for
the Java client.
Maestro Resource Authoring Guide (Web client) Information on creating and managing resources, including
workbooks, dashboards, and forms. Detailed information about
Maestro Query language is also included. Procedures in this
guide are for the Web client.
Maestro Data Model and Algorithm Guide (Java Description of the Maestro data model and associated
client) algorithms. All tables and fields in the data model are listed and
described. This guide also notes changes to the data model
corresponding to the Maestro release. Procedures in this guide
are for the Java client.
Title Description
Maestro Data Model and Algorithm Guide (Web Description of the Maestro data model and associated
client) algorithms. All tables and fields in the data model are listed and
described. This guide also notes changes to the data model
corresponding to the Maestro release. Procedures in this guide
are for the Web client.
Data model posters A series of posters illustrating the structure of tables and fields in
Maestro, and the relationships between fields. For a list, see
"Data Model Posters" on page 29.
Maestro Scripting Guide (Java client) Information about building custom applications using scripting
language objects, functions, and methods to automate some
Maestro processes. Procedures in this guide are for the Java
client.
Maestro Scripting Guide (Web client) Information about building custom applications using scripting
language objects, functions, and methods to automate some
Maestro processes. Procedures in this guide are for the Web
client.
Maestro Web Services Guide Information on using Maestro Web services to create users,
resources, and Web service client programs.
Maestro Data Integration Guide Information about integrating enterprise data sources with
Maestro, including mapping data from source tables and fields,
customizing the Maestro database, extracting data from
enterprise sources, performing data updates to bring new and
updated data into Maestro, moving data between Maestro
instances, and moving data changes between Maestro and
business partners in real-time.
Maestro User Guide (Mobile Client) Information on how to view data in the Mobile client.
Global Help If you aren't sure which help system contains the information
you need, search in Global Help. It includes information from all
of the help systems.
Title Description
Maestro Release Summary The latest release summary outlines all of the changes that have
been made in Maestro 2507, including new features and defect
resolutions in service updates. Release summaries can be found
in the Kinaxis Knowledge Network in the Documentation Center.
Custom Help Your company might have created custom help specific to your
Maestro implementation.
Documentation conventions
To help you quickly locate and interpret information, Kinaxis guides use conventions noted in
the following table.
Courier New Courier New is used for programming examples and text that is entered in Microsoft
Windows Command Prompt window or command lines.
If you are using a Mac OS, procedures that use the Windows Ctrl key should be replaced with the
Mac OS Command key.
Note: If you don't want the words you searched for highlighted in the help topic, click
Remove Highlights .
Tip: If the browser window is small, the search bar might not be displayed. To see a
search bar, click or enlarge the window.
Tip: If the browser window is small, the Contents and Index panes might not be
displayed. To see them, click or enlarge the window.
Your feedback
Kinaxis takes great pride in developing user-friendly applications and we hope that our
documentation resources ensure a high level of usability. We welcome your feedback about the
help topics you access.
Help in resources
Many resources have help embedded within them. The form that this help takes depends on the
type of resource.
When help is available for a resource, you can view it from the open resource.
You can also view an Help overview that describes the purpose of the resource for some types of
resources from the Explorer, without having to open the resource first. These resources include
workbooks, scorecards, forms, and scripts. Viewing resource help from the Explorer can help you
to determine whether a resource is the right one to use, without waiting for it to load.
Tip: You can also view resource help from the Explorer by right-clicking the name of the
resource and then selecting the Help option for the resource from the menu. For
example, to view help for a script, click Script Help.
Note: This option is only available for workbooks that have workbook help or help for at
least one worksheet.
Note: Help is printed as it appears in the help pane. Widen the help pane before printing
to maximize the amount of information printed on a page.
Tip: You can also print the help by right-clicking in the help pane, and then clicking
Print.
Note: This option is available only for scorecards that have help.
Note: Help is printed as it appears in the help pane. Widen the help pane before printing
to maximize the amount of information printed on a page.
Tip: You can also print the help by right-clicking in the help pane, and then clicking
Print.
Note: As of Service Update 2408, dashboards are automatically opened in the Web
client (see the Maestro User Guide (Web client)). If you're using an older version of
Maestro, see Viewing data in dashboards.
Note: Controls for pop-up help are only displayed when it is available.
Some content is only available after you create a Kinaxis Knowledge Network user account and
sign in.
Training courses
Kinaxis offers instructor-led courses and self-paced online training courses to help you develop
in-depth Maestro knowledge. Instructor-led courses are usually delivered online in a virtual
classroom, but on-site instruction can also be arranged. To see the training paths and courses
that are available, visit www.kinaxis.com/learningservices.
This section describes all the new scripting features introduced in recent Maestro releases. There
are similar chapters in other guides. For more information, see "Determining which help system
or guide to use" on page 27.
Note: Descriptions of changes that occurred more than two years ago are removed at the
beginning of each year.
You can also earn more about the new features and changes included in Maestro from the
Maestro Release Summary Guide.
A new version of the Maestro Release Summary Guide is released with each new version of
Maestro, including service updates.
This document is available for download from the Kinaxis Knowledge Network and summarizes
the changes to Maestro. It contains a compilation of changes gathered from every
RapidResponse guide and help system. It also contains lists of defects resolved in each version.
Tip: You can also find release summary content in the Global Help system.
Deprecated methods
The generate and getChart methods are no longer supported. For assistance with scripts that
use either of these methods, contact the script author or Kinaxis Customer Support.
List arguments
You can now define arguments that contain a list of values, which script users can use to select
from a set of available options. You can use this to allow users to customize script operations
that are controlled by the values present in the list. You can also use this to control options
available when a user must provide a value, such as by presenting a set of options instead of
using a string argument where they can specify any value.
Items in a list argument consist of a display value that is shown to the user running the script and
an optional data value that is passed to the argument. You can use this to provide a descriptive
Maestro scripts allow you to build custom applications using scripting language objects,
functions, and methods to automate some Maestro processes. Scripts are executed on the
Maestro Server, and perform operations using Maestro resources and data. For example, you can
create scripts to perform any of the following operations:
l Automating part of a simulation process.
l Creating historical scenarios or scenarios required by a process.
l Running automatic data modifications as part of a process.
l Retrieving worksheet data.
l Performing date arithmetic.
l Sending messages.
l Automating Maestro Server commands.
l Modifying data.
Most scenario management options are available through scripts. You can use a script to create,
rename, update, commit, or delete a scenario. You can also access workbooks to run commands,
retrieve worksheet data, or perform date calculations. A script can combine any of these
operations. For example, you can calculate the difference between the current date and the last
date a scenario was accessed, and then delete any scenarios that have not been accessed in a
specified number of weeks.
If you are a system administrator, you can run Maestro Server commands to perform system
administration tasks such as checking data integrity or restarting the server.
Note: When you create scripts from a command that automatically modifies data in a
shared scenario, users must have permission to edit data in shared scenarios.
1. The user views the form, types information and makes selections in the controls, and then
clicks the action button "Respond". Any form-level validation errors, such as leaving a
required control blank, must be resolved before the form can be run.
2. If the form has all its required controls defined with appropriate values, the form passes
those values to the corresponding arguments in the underlying script.
3. The script executes the action or actions it has been authored for. This script manages
scenarios and sends a message.
4. Optionally, the script can return an error or success message back to the form for the user
to view.
In the Maestro Web client, form authors can generate forms based on existing scripts or build
new forms and then generate script arguments mapped to controls on the form. The generated
script only contains the arguments and does not constitute a functioning script.
As a script author, you may be responsible for completing the generated script for a form by
adding all the required body material, including validation, business logic, and error handling, to
make the script functional.
The image below shows the Scenario Response form and how its controls map to arguments in
the generated script.
You might also be responsible for editing existing scripts in response to changes made in
corresponding forms based on the scripts.
Form authors either generate, or select, the script that's run when the user clicks the form's
action button. They can then map script arguments to the appropriate form fields through the
action button's properties. This ensures that the script's arguments are associated with controls
that can pass the required values to them.
A script is composed of its code, arguments that provide data values, dependent resources that
the script uses, and help for users. The dependencies can be workbooks or scripts. Dependent
workbooks allow the script to run workbook commands or retrieve data from worksheets.
Dependent scripts allow the script to use functions from or run the dependent script. To enable
workflows to run the script, you can set the script to be available to workflows.
You should plan the actions performed by a script and the data required for those actions before
you begin creating the script. The data required by the script is obtained by creating script
arguments that take values or by running other scripts. You can also use functions from other
scripts and run them as part of the script or take the output values of a workflow and use them in
a script.
Item Description
Validate Validates the script syntax to find unmatched parentheses and invalid structure. This does
Script not validate function calls, method calls, or declarations.
Run Script Validates function calls, method calls, and declarations, and runs the script.
More Opens the script properties, where you can view, add, or modify arguments, dependencies,
Properties and help.
Find Search for specific text in the script code editor or console.
Developer Opens the Advanced Topics section of the Kinaxis Knowledge Network.
Forum
Output console
After you run a script, the output console displays any debugging messages specified in the
script and the script's return value. You can use this to test your script and to find where a script
is failing. If the script does not complete, the error message is displayed in the console, as shown
in the following illustration.
The output console displays the last 32 kilobytes of text output from the script. You can also view
the output in the script log, which displays the last 5,120 characters of output. For more
information, see "Script logging" on page 94.
If you cancel a script, its debugging messages are not displayed in the console. The message
shown in the following illustration is displayed instead.
In this case, you can view the messages in the script log. For more information, see "Script
logging" on page 94.
1. In either the code editor or console, select or place the insertion point in the text you want
to search for.
2. Press F1.
3. In the Search window, select the topic you want to review.
Scripts can support as many arguments and dependencies as you require, but each argument
must use a unique name within the script.
Create a script
1. On the File menu, point to New, and then click Script.
2. In the New Script dialog box, on the General tab, type a name for the script.
3. If the script will be used by a workflow, select the Make available to workflows check
box.
4. Create the scripting code. For more information, see "Create script code" on page 57.
5. Define arguments that pass input values into the script. For more information, see "Define
arguments for a script" on page 62.
6. Specify any scripts or workbooks that are required for the script. For more information, see
"Specify dependencies" on page 68.
7. Write help for script users and notes for other script authors. For more information, see
"Adding help for scripts" on page 73.
8. Test the script to ensure it functions as you expect. For more information, see "Test a
script" on page 70.
Note: You can perform steps 3 to 6 in any order. For example, you could create
arguments before writing script code, or write code, define a dependency, and then
resume writing code.
Tip: You can also create a script by clicking New Resource on the Maestro toolbar.
Script versioning
If your company has enabled resource version control, each script you create can be added to
the repository, which allows you to share it with other users, records revision notes, and revert
changes to an earlier version if necessary.
For complete information about resource version control, see the Maestro Resource Authoring
Guide (Java client).
Scripts you create must contain a global function named main(), which is used as the start of
the script. Other functions and methods can be called from the main() function. The main()
function is included by default when you create the script, and should not be removed, unless
you are creating a script to be used as a library in another script. For more information, see
"Guidelines for creating scripts to be used by other scripts" on page 71.
If you specify a return value for the main() function, that is the value the script returns.
Otherwise, the script does not return a value. The script's return value is displayed in a dialog box
after the script completes, and is displayed if you run the script from the Explorer or from the
Run Automation Task dialog box, or if you run a workbook command that runs the script. The
return value is also visible in the script log. For more information, see "Script logging" on page
94.
For information about the objects and methods you can call in scripts, see "The rapidResponse
script object model" on page 100.
All object properties, unless otherwise indicated, cannot be modified by a script. Values for
properties are specified when the object is retrieved, and cannot be changed.
If your company has access to a test system, you should do all script development and testing on
that test system, and then move the script into your production system. This allows you to test
the functionality of the script without fear of causing errors in production or disrupting your
Maestro user community. For more information about test systems, see the Maestro
Administration Guide.
You can search for information about scripting objects and methods as you write your script
code. For more information, see "Search the scripting help" on page 55.
Maestro scripts run using the Google V8 scripting engine, and allow you to use Javascript and
ECMAscript features supported in Google V8 version 11.9. Although these features are
supported, the sample code included in the guide focuses only on methods and objects defined
in therapidResponse object.
Note: If you are creating a script that modifies data in a scenario with a scope property
of "Public", users must have permission to edit data in shared scenarios.
The argument array is created at script runtime and the values set using the values passed from
the command or process that runs the script. The argument array and its values are read-only
and cannot be modified afterward. All arguments you need to use must be defined in the script
properties and values for them must be specified when the script runs.
When using file arguments, you must use the toString() or toBase64() function to get the
contents of the file or to convert an image file to a base64-encoded string the script can process,
as shown in the following examples:
var fileContent = rapidResponse.scriptArguments["fileArgumentName"].toString
();
The following illustration shows methods available for the scenarios collection. Some of these
methods are also valid for the scripts or workbooks collections.
Inserting a method using the list also inserts the method's parameters, which you can customize.
For information about the objects, properties, and methods you can use, see "The rapidResponse
script object model" on page 100. For more information about collections and the methods that
can be called from them, see "Resource collections" on page 107.
Tip: You can use shortcut keys Ctrl+z (Undo), Ctrl+y (Redo), and Ctrl+s (Save) in the
script editor.
1. In either the code editor or console, select or place the insertion point in the text you want
to search for.
2. Press F1.
3. In the Search window, select the topic you want to review.
Error handling
You can handle errors by using a try/catch/finally structure, that catches the errors you want to
check for. You should also include a throw clause to ensure any unexpected errors are caught.
The exception object that the rapidResponse object model throws has a name property with the
value "RapidResponseError", and an errorCode property with values that for resource-related
errors are defined using the convention ResourceType.ErrorCondition. For example, a scenario
not found error can be caught using the following syntax in a catch block:
catch (error) {
if (error.name == "RapidResponseError" && error.errorCode ==
"Scenario.NotFound") {
return ("The specified scenario does not exist.");
}
throw error;
}
When an error is caught, you can choose to report the error in the validation console and
continue running the script, to return an error message, or to terminate the script by throwing
the error. You can also access a stack trace for the error. For more information about exceptions,
see "Exception object" on page 346.
Adding comments
You can convert lines of code into comments by doing the following:
Notes:
l You can place the insertion point anywhere in a line of code before clicking Toggle
Comment. The entire line is commented.
l If you click Toggle Comment when you have a commented line of code selected,
that line is no longer commented.
If the script is used in a workbook command, the workbook's author can specify default values
for the arguments. For more information, see the Maestro Resource Authoring Guide (Java client).
If the script is used in a workflow, the script must be made available to workflows by selecting
the Make available to workflows check box in the Script Properties dialog box.
For more information, see the Maestro Resource Authoring Guide (Java client).
Type Description
Boolean Passes a JavaScript Boolean object into the script. You can use this type of argument in cases where
only two options are available.
Date Passes a JavaScript Date object into the script. You can use this type of argument to specify a
minimum or maximum date to consider in worksheets.
File Passes information from a file into the script. You can use this type of argument to integrate
information contained externally in files into Maestro. The file used in the script must be encoded as
either Unicode or UTF8.
When running the script directly, you provide the path to any local file. When running the script
through a scheduled task, the file must be located in a pre-configured Maestro file location. You
configure file locations in the File Locations worksheet in the RapidResponse Administration
workbook. To open this workbook, in the Administration pane, under System Settings, click
Configuration. For more information, see the Maestro Administration Guide.
If you are running the script from a Web service, you must present the file content as a base64-
encoded string. For more information, see the Maestro Web Services Guide.
A file argument can be used to set a profile picture for a user. To set an image as a profile picture, the
image file object must be converted to a base64-encoded string. This is achieved using the toBase64
() method. For example:
var profilePictureString = rapidResponse.scriptArguments
["profilePicture"].toBase64();
Number Passes a numeric value into the script. You can use this type of argument to specify any numerical
data, such as a minimum value to use in a filter expression, or a number of calendar periods to add or
subtract from a date.
Scenario Passes a Maestro Scenario object into the script. You can use this type of argument to define a parent
scenario for scenarios created by the script.
This is the only Maestro resource that can be passed as an argument.
String Passes text into the script. You can use this type of argument to specify a name for a scenario to
create, or to specify a specific part to filter a worksheet using.
List Passes a value selected from a list into the script. You must specify the list values available, which can
be a static list of values or based on a query that reads values from a specific table and field. List
values consist of a display value that is shown to the user running the script and an optional data
value that is the actual value passed to the script. For example, you could define a list that displays
names but passes identifiers or specific values that are enumerated in the script. If you do not define
a data value, the display value is passed to the script, so you must design the script to work with the
values you are passing to it.
Note: If you create an argument with the same name as a reserved keyword for script
logging, the script is not included in the Script Log worksheet of the Automation Detials
and Log workbook. To ensure your scripts are logged, do not create arguments named
any of the following: "ScriptName", "ScriptScope", "Duration", "Status", "Console",
"CanceledByUserId", "Id", or "Source".
For information about using arguments in the script, see "Using script argument values" on page
58.
Resource Context
For scripts that run from workbooks, forms, scheduled tasks, or workflows, additional arguments
are available to determine the context the script was run with. This ensures that the values
required by the script are passed from the workbook, form, scheduled task, or workflow to the
script.
You can use the following context arguments to pass the resource settings to a script:
Name Description
#Workbook The workbook that the script runs from.
#WorksheetSelection The values selected in the worksheet when the script ran.
#WorkflowExecutionId The workflow ID in GUID format that the script was run from.
#TaskActivityId The scheduled task execution the script runs from. This generates a new value every
time and associates the script execution with a particular run of the scheduled task.
Copy an argument
1. In the New Script or Script Properties dialog box, click the Arguments tab.
2. Select the argument you want to copy, and then click Copy.
3. In the New Argument dialog box, type a name for the new argument.
4. Specify the default value for the new argument.
5. Type a label for the argument.
6. Type a description for the argument.
Modify an argument
1. In the New Script or Script Properties dialog box, click the Arguments tab.
2. Select the argument you want to modify, and then click Edit.
3. Modify the name, default value, label, or description for the argument.
Specify dependencies
Scripts can depend on other resources for functionality. For example, you can call a function
from another script or use a workbook to perform an automatic data modification. Specifying
resources as dependencies ensures that the scripts or workbooks are always available to users
you share the script with, and exports a copy of a dependent script or workbook if you export the
script. You can define the following types of script dependencies:
l included scripts that act as libraries, providing functions and variables the script can use.
l referenced scripts that can be called.
l referenced workbooks that can run automatic data modifications.
You can use any of the functions defined in an included library script. You must ensure the
functions and variables in your script do not have the same names as the functions and variables
in the library script. For more information, see " Notices" on page 80 and "Call a function from an
included script" on page 71.
Reference a script
1. In the New Script or Script Properties dialog box, click the Dependencies tab.
2. In the Referenced resources area, click Add, and then click Script.
3. In the Select Scripts dialog box, select each script you want to include, and then click
Add.
Reference a workbook
1. In the New Script or Script Properties dialog box, click the Dependencies tab.
2. In the Referenced resources area, click Add, and then click Workbook.
3. In the Select Workbook dialog box, in the Workbook list, click the workbook you want to
include.
Remove a reference
1. In the New Script or Script Properties dialog box, click the Dependencies tab.
2. In the Referenced resources area, select the script or workbook you want to remove, and
then click Remove.
Test a script
Before you deploy your script, you can test it by doing either of the following:
l Validating the script syntax.
l Running the script.
Validating the syntax finds any missing parentheses, mismatched parentheses, and malformed
expressions. However, validating does not find incorrect function and method calls, variable
definitions, or object usage. The result of validating the script is displayed in the output console.
Running the script executes the code, and either outputs the specified messages to the console,
or reports any error conditions in the console. To view the error conditions, you should run the
script from the script authoring window.
Messages are written to the console only if the script runs to completion. If you cancel the script,
you can view the console output in the Automation Details and Log workbook. For more
information, see "Script logging" on page 94.
Validate a script
1. In the Explorer, right-click the script you want to validate, and then click Properties.
2. On the script authoring window toolbar, click Validate Script .
3. Examine the output console.
Note: If you are testing a script as you are editing it, the script is automatically saved
when you run it.
If the script's author has provided help, you can view information about the functions defined in
the included script in that script's help or author notes. For more information, see "View script
help" on page 93.
You can provide values for any arguments the script takes. Arguments are specified as an object
that defines the argument names and the values passed to them. If you do not provide a value
for an argument, its default value is used. However, if you specify a value for an argument that
Call a script
1. Get the script object you want to call. For example,
var callScript = rapidResponse.scripts.get({name:"Delete Child",
scope:"Public"});
2. If the script returns a value, declare a variable to hold that value.
3. Call the script using the script's call() function
callScript.call({scenario: myScenario});
or
var scriptOutput = callScript.call({scenario: myScenario});
Notes:
l This example assumes a scenario object named myScenario was created previously in
the script.
l For more information, see "call method" on page 138.
Edit a script
You can modify the code or properties of any script you own. For example, you can define new
arguments, modify existing arguments, add or remove dependencies, add or remove functions,
and add or remove method calls and function calls.
If your company uses resource version control, you must check out any shared script you modify.
For more information, see the Maestro Resource Authoring Guide (Java client).
If you modify a shared script and add a dependency, that dependent workbook or script is
automatically shared with the other users that have access to the script.
Edit arguments
1. In the Explorer, select the script you want to modify.
2. On the Actions menu, click Properties.
3. On the script authoring window toolbar, click Properties .
4. In the Script Properties dialog box, click the Arguments tab.
5. Select the argument you want to modify, and then click Properties.
6. Modify the argument's name, label, or default value. For more information, see "Define
arguments for a script" on page 62.
7. Update the code to refer to the new or modified arguments.
Copy an argument
1. In the Explorer, select the script you want to modify.
2. On the Actions menu, click Properties.
3. On the script authoring window toolbar, click Properties .
4. In the Script Properties dialog box, click the Arguments tab.
5. Select the argument you want to copy and then click Copy.
6. Specify a new name for the copied argument and modify other properties accordingly.
7. Update the code to refer to the new argument.
8. Do one of the following:
l To save the changes, on the File menu, click Save Script.
l To save the changes as a new script, on the File menu, click Save Script As, and then
specify a name for the new script.
9. Test the changes. For more information, see "Test a script" on page 70.
Delete an argument
1. In the Explorer, select the script you want to modify.
2. On the Actions menu, click Properties.
3. On the script authoring window toolbar, click Properties .
4. In the Script Properties dialog box, click the Arguments tab.
5. Select the argument you want to delete, and then click Delete.
6. Update the code to remove references to the deleted argument.
7. Do one of the following:
l To save the changes, on the File menu, click Save Script.
l To save the changes as a new script, on the File menu, click Save Script As, and then
specify a name for the new script.
8. Test the changes. For more information, see "Test a script" on page 70.
Tip: You can also edit a script by selecting it in the Explorer, and then pressing ALT
+ ENTER.
Managing scripts
You can perform resource management operations on scripts, including copying, giving, sharing,
importing, exporting, and deleting. For complete information about managing resources, see the
Maestro Resource Authoring Guide (Java client).
Notices
Notices can be success notices, error messages, warnings, general information, or questions.
Each message type displays in a different color and style. Depending on how you define the
notice, you can add predefined or custom buttons for users to interact with or you can set the
notice to automatically close. For more information, see " Notices" on page 80.
Control errors
Control errors display on a control in response to an invalid value. The message displays until the
user corrects the error and runs the form again. All input controls, except for checkbox controls,
can display a control error. For more information, see "Control errors" on page 82.
return Form.response ({
notice:notice,
data: {
scenarioKey: {
name: 'My Scenario',
scope: 'Private'
}
}
});
Tip: You can create different types of messages with OK, Cancel, Yes, and No buttons by
specifying those button labels in custom buttons.
Notice prompts
This type of message displays briefly and then automatically closes the form. No buttons display
on a notice prompt. For example, you might create a prompt message to inform users about
how many new orders were inserted.
The code sample below outlines how to create a notice prompt.
Control errors
You can create custom error messages on form controls that display after the form validation has
completed and the form is run. Control errors are defined using ControlMessage objects in the
script and passed back to the form in an errorResponse.
1. Sign in to the Kinaxis Knowledge Network and then access the Sample scripts page.
2. Click the link for the Sample Scripts.zip file.
3. Specify a location to save the file, and then click OK.
4. Open the Sample Scripts.zip file, and extract the sample scripts.
5. In Maestro, import the Sample: Create Monthly Scenario.spt file. For more information,
see the Maestro Resource Authoring Guide (Java client).
This script catches three specific exceptions that can be thrown when attempting to create a
scenario. These exceptions return custom error messages. Other exceptions are caught and re-
thrown, which terminates the script with the exception's error message.
1. Sign in to the Kinaxis Knowledge Network and then access the Sample scripts page.
2. Click the link for the Sample Scripts.zip file.
3. Specify a location to save the file, and then click OK.
4. Open the Sample Scripts.zip file, and extract the sample scripts.
5. In Maestro, import the Sample: Historical Scenario Management.spt file. For more
information, see the Maestro Resource Authoring Guide (Java client).
This script defines functions that perform date calculations and manage scenarios.
//The listed arguments are created by defining arguments on the Arguments tab
of the script properties dialog box.
function main() {
var scenario = rapidResponse.scriptArguments["scenario"];
var site = rapidResponse.scriptArguments['site'];
var customer = rapidResponse.scriptArguments['customer'];
var partName = rapidResponse.scriptArguments['partName'];
var quantity = rapidResponse.scriptArguments['quantity'];
var dueDate = rapidResponse.scriptArguments['dueDate'];
var orderNumber = rapidResponse.scriptArguments['orderNumber'];
var orderType = rapidResponse.scriptArguments['orderType'];
var highPriority = rapidResponse.scriptArguments['highPriority'];
var quantityMultiple = 5
var argumentErrors = [];
if (quantity % quantityMultiple != 0)
{
throw Form.errorResponse ({
controlMessages:[Form.argument.Error("quantity","Quantity must be a
multiple of " + quantityMultiple + ".")]
});
}
if(!orderNumber || orderNumber.length == 0)
{
orderNumber = 'Forms.Order' + customer;
}
//Shortcut for an IF statement, where if the order priority is high, then the
value is specified as high, else it is specified as med.
//Calling the workbook and specific worksheet to import values from the form
into.
//Cells aligned to column order and ID in the worksheet are created to pass
values from the form into the workbook.
if(result.inserted != 1) {
var notice = null;
notice = Form.okCancelNotice("Are you want to commit the order in this
scenario?", Form.runScriptAction("ok"), Form.runScriptAction("cancel"));
return Form.response ({
notice:notice,
data: {
scenarioKey: {
name: 'My Scenario',
scope: 'Private'
}
}
});
}
worksheet = workbook.worksheets.get("GetFilteredOrder");
A script you own or that has been shared with you can be run in any of the following ways:
l From the Run Automation Task dialog box.
l From the Explorer.
l Using a form. See "About forms" on page 48.
l Using a workbook command. See the Maestro Resource Authoring Guide (Java client).
l Using a scheduled task. For more information, see "Schedule a script to run automatically"
on page 94.
l By a Web service client, as discussed in "Running scripts from Web services" on page 96.
For more information about sharing scripts with other users, see the Maestro Resource Authoring
Guide (Java client).
When you run a script, you can specify values for each of its arguments, as shown in the following
illustration.
Caution: If you run a script from the Explorer, you are prompted to cancel the script after
it has been running for 20 seconds. If you do not cancel the script, you must wait for it to
complete. However, if you cancel the script, any operations it has performed are not
reverted. Depending on the operations the script performs, canceling the script could
leave your system in an unstable state.
If a user who is not a script author runs the script, or you schedule it or run a workbook
command that calls it, only a Maestro administrator can cancel the script. For more information,
see the Maestro Administration Guide. For more information about running workbook
commands that call scripts, see the Maestro User Guide (Java client).
Run a script
1. On the Maestro toolbar, click Run Automation Task .
2. In the Run Automation Task dialog box, select the script you want to run, and then click
OK.
3. If prompted, specify values for the listed arguments on the Settings tab.
4. Click OK.
Note: If no help is defined for the script, the tabs don't display and the Run Script dialog
box only displays the script arguments.
Tip: You can also run a script from the Explorer by right-clicking the script you want to
run, and then clicking Run Now.
Note: The Script Help tab only displays if help is defined for the script.
Script logging
When you run a script, its result is recorded in the Automation Details and Log workbook's Script
Log worksheet. The Script Log contains details about the script, including when it ran, how long
it took to run, the result of running it, and the script's console output, which includes error
information if the script failed. You can use the Script Log to view your script history.
Scripts are logged after you run them from the script authoring window, the Run Automation
Task dialog box, a workbook command, or a scheduled task. An example of script log entries is
shown below.
For scripts that write output to the console, the messages are also reported in this worksheet. If
you cancel the script, this worksheet is the only place you can view the messages. The messages
are displayed in the worksheet, with a link to the complete console output, as shown in the
following illustration.
Note: For more information about the Automation Details and Log workbook, see the
Maestro Resource Authoring Guide (Java client).
Property Description
alerts The collection of alerts available to the script. For more
information, see "alerts collection" on page 298
The resources that can be defined as objects and used in a script are defined as one of the
following types.
Alert Defines alert properties and provides methods for managing and running alerts.
For more information, see "Alert objects" on page 298.
Automation Defines automation chain properties and provides methods for managing and running
chain automation chains.
For more information, see "AutomationChain objects" on page 324.
Profile Defines profile variables and provides methods for retrieving and setting values in variables.
variable For more information, see "ProfileVariable objects" on page 350.
Scenario Defines scenario properties and methods, including methods for creating, updating, committing,
or deleting scenarios.
For more information, see "Scenario objects" on page 140.
Scheduled Defines scheduled task properties and provides methods for managing and running scheduled
task tasks.
For more information, see "ScheduledTask objects" on page 308.
Scorecard Defines scorecard properties and provides methods for managing scorecards.
For more information, see Scorecard objects.
Script Defines script properties and methods for calling another script.
For more information, see "Script objects" on page 130.
Workbook Defines workbook properties and data modification commands. Includes methods for retrieving
data from a workbook and running commands.
For more information, see "Workbook objects" on page 176.
Worksheet Defines worksheet properties and provides methods for retrieving worksheet data and
performing data modifications.
For more information, see "Worksheet objects" on page 206.
All resource types have common properties and methods, which are defined by the abstract
Resource object. Each resource is defined by an object that implements the Resource object. All
resource objects are contained in resource collections, which provide additional methods for
managing resources. For more information, see "Resource collections" on page 107.
Resource objects contain the following properties.
id String The resource's identifier. This value is used to identify the resource within its
resource collection.
usageCount Number The number of times the resource has been accessed.
accessControlList Object A collection of users and groups who have access to the resource.
For more information, see "accessControlList collection" on page 119.
HelpInformation object
The HelpInformation object provides access to the Maestro Help. This object contains the
following properties.
customHelpLabel String The label displayed for your company's custom help.
customHelpUrl String The address your company's custom help is available from.
LOCAL_URL String The HTTP URL base for the local Maestro help. Help links use this base to
locate the help systems.
ONDEMAND_URL String The HTTP URL base for the online Maestro help. Help links use this base to
locate the help systems.
Resource collections
The resources available to the script are stored in collections, with each type of resource stored
in its own collection. For example, the workbooks collection contains all workbooks available to
the user running the script.
To use a resource in the script, it must be retrieved from the collection, typically by referring to
its resource key, which is defined as an object with the following properties from the resource
object.
Resources in collections can also be retrieved using an identifier, or by an array index. For more
information, see "Collection indexing" on page 108.
Collections also support the standard JavaScript iteration functions. For more information, see
"Collection iteration functions" on page 109.
The following methods are defined for resource collections. Each resource type can implement
these methods differently, and can require different parameters or throw different exceptions.
For example, the workbooks collection has an optional parameter defined for its get method.
In addition, some resource types do not implement all collection methods, which means you
cannot use that method for that resource type. For example, the scripts collection does not
implement the create method, so you cannot create a script using a script.
Method Description
get(key) Retrieves the resource object with the specified resource key.
Collection indexing
Resource collections are indexed by the id property of the objects within the collection. These
values are unique within the collection, and are typically used internally by Maestro to identify
the resource object. You can retrieve or refer to an object by its identifier, if it is known. For
example, the following retrieves a collection object using its id property.
collectionObject = collection[id];
where collection is a resource collection.
For most resources, the id is a GUID. However, for scenarios, the id is identical to the scenario's
sequence number. See "Obtaining scenario sequence numbers" on page 153.
In some cases, retrieving a resource by it's id property can reduce errors, because you do not
need to know the resource's scope. The id does not change if a resource is shared, so as long as
you can get that value, you can retrieve the resource no matter its scope. In addition, if a
resource is renamed, its id does not change.
You can use these functions to perform operations on items in a collection without specifying
the exact name or identifier for each item. For example, if you expect the items in the collection
to change over time, these functions allow you to create a script that performs its function no
matter how the collection is modified.
Syntax
resource = rapidResponse.resourceCollection.get({name:"name", scope:"Public
or Private"});
where resourceCollection is the collection to retrieve the resource from.
scope String Whether the resource is Public or Private. For more information, see "Using resources
as objects" on page 57.
Returns
Type Description
Object A Resource object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
The ResourceType depends on the type of resource you are retrieving, For example, if you are
retrieving a scenario, the NotFound exception is Scenario.NotFound.
Example
To retrieve a scenario object:
exists method
Determines whether a resource exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified resource after this method
runs. If you are using this method to test whether a resource exists, you should still catch a
NotFound exception for the resource type you are using.
Syntax
resourceExists = resourceCollection.exists({name: "Name", scope: "Public or
Private"});
where resourceCollection is the collection to delete the resource from.
Returns
Type Description
Boolean l true if the resource exists
l false if the resource does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
create method
Creates a resource in the specified resource collection.
Syntax
newResource = resourceCollection.create(name);
where resourceCollection is the collection you are creating the new resource in.
Returns
Type Description
Object A Resource object.
Exceptions
The create method can throw the following exceptions.
Exception Description
ArgumentError The specified resource name is blank or undefined.
ResourceType Either a resource with the same name already exists or the specified name is not valid
.NameValidationError for the resource type.
The ResourceType depends on the type of resource you are creating, For example, if you are
creating a scenario, the NoPermission exception is Scenario.NoPermission.
Syntax
rapidResponse.resourceCollection.remove(resourceName);
where resourceCollection is the collection to delete the resource from.
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
ResourceType.NoPermission You do not have permission to delete the specified scenario.
The ResourceType depends on the type of resource you are deleting, For example, if you are
deleting a scenario, the NotFound exception is Scenario.NotFound.
Example
To delete a script:
Method Description
give(newOwner) Changes the owner of a resource.
makePublic() Changes the scope of a resource to "Public", which is the equivalent of sharing the
resource. Public resources can be accessed by administrators and users and groups
with access.
give method
Gives a resource to another user by changing the resource's owner. You can give any resource
you own.
If the resource is shared with other users, you can still access it after giving it. However, if the
resource is private, you cannot access it after you give it.
Syntax
resource.give(newOwner)
Returns
No return value.
Exceptions
The give method can throw the following exceptions.
ResourceType The specified user already owns a resource with the same name as the one you are
.NonUniqueName giving.
ResourceType The resource does not allow the give operation or you do not have permission to give
.NoPermission the resource.
The ResourceType depends on the type of resource you are giving, For example, if you are giving
a scenario, the NonUniqueName exception is Scenario.NonUniqueName.
Example
To give a scenario:
makePublic method
Changes the scope of the specified resource from "Private" to "Public". This method does not
specify other users or groups to share the resource with, so it is available to only you and
administrators.
If you call this method on a variable that represents a resource, you must ensure you assign the
returned public resource to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the resource with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared resource, and you can allow other users and groups to
access a shared resource.
Making a resource public also adds it and any dependent resources to the resource repository.
The script that calls this method is included in the repository notes, and the version is
automatically saved as 0.1. For more information about the repository, see the Maestro Resource
Authoring Guide (Java client).
Returns
A Resource object that represents the same resource with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions
Exception Description
ResourceType.NotFound The specified resource does not exist.
ResourceType.NonUniqueName A shared resource with the same name as the one you are sharing already exists.
The ResourceType depends on the type of resource you are sharing, For example, if you are
sharing a scenario, the NonUniqueName exception is Scenario.NonUniqueName
Example
To share a scenario:
rename method
Changes the name of a resource. You can rename only private resources that you own.
Syntax
resource.rename(newName)
Returns
No return value.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank, invalid string, string or null value was specified for the newName
parameter.
ResourceType Either a resource with the same name already exists or the specified name is not valid
.NameValidationError for the resource type.
The ResourceType depends on the type of resource you are renaming, For example, if you are
renaming a scenario, the NonUniqueName exception is Scenario.NonUniqueName
Example
To rename a scenario:
copy method
Creates a new private resource by copying an existing resource. If you copy a shared resource,
the copy is private.
If the resource you are copying has dependencies, the new resource has the same dependencies.
Returns
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
ResourceType Either a resource with the same name already exists or the specified name is not valid
.NameValidationError for the resource type.
The ResourceType depends on the type of resource you are copying, For example, if you are
copying a script, the NonUniqueName exception is Script.NonUniqueName
Example
To copy a script:
createBookmarkDefinition method
This method creates a bookmark for any one of these resources: workbook, dashboard, form,
script, or scorecard.
Returns
A bookmark for the specified resource.
Exceptions
The createBookmarkDefinition method can throw the following exception.
Exception Description
ArgumentError No argument or more than one argument was specified for the method.
Example
function main() {
const actions = rapidResponse.clientActions;
// Dashboard
const dashboard = rapidResponse.dashboards.get({name: 'Adoption
Dashboard', scope: 'Public'});
const dashboardBookmarkDef = dashboard.createBookmarkDefinition();
actions.addBookmark(dashboardBookmarkDef);
// Return client actions
return JSON.stringify(actions);
}
accessControlList collection
Access to a resource can be granted or denied by adding or removing users from the
accessControlList collection for that resource object. Each resource object has an
accessControlList collection, which contains objects with the following properties.
level String How the user or group can access the resource. This reports only how the resource
was directly shared with the user or group, and does not include any resources
assigned through group memberships. For more information about groups, see
"GroupCollectionObject object" on page 519.
This property can contain one of the following values:
l Full: The user or group has administrative permissions for the resource,
including modifying, deleting, sharing, or giving it to other users. This
level does not apply to scenarios.
l Modify: For scenarios, the user or group can modify data in the scenario.
For other resources, the user or group can modify the resource
properties.
l View: For scenarios, the user or group can only view data in the scenario.
For other resources, the user or group can open, run, or use the resource,
depending on the resource type.
The accessControlList collection defines the following methods, which are available to all
resource types unless indicated otherwise.
Method Description
add(principal, Shares the resource with the specified user or group with the specified access level by adding that
level) user or group to the collection.
remove Remove access for the specified user or group by removing that user or group from the collection.
(principal)
remove method
Removes resource access from the specified user or group. If you remove access from all users or
groups, the resource remains shared and can be accessed by administrators.
Syntax
resource.accessControlList.remove(principal);
Exceptions
The remove method can throw the following exceptions.
Exception Description
ResourceType.NoPermission You do not have permission to modify the access control.
The ResourceType depends on the type of resource you are removing access from, For example,
if you are removing access to a scenario, the NoPermission exception is Scenario.NoPermission.
Example
To remove access from a scenario:
add method
Shares a resource or scenario by adding the specified user or group to the list of users and
groups that have access to the resource. Sharing a private scenario or resource using this
method makes that scenario or resource public (or shared), so you can call this method instead
of calling the makePublic() method. For more information, see " makePublic method" on page
115.
If you are sharing a scenario, you can use the Scenario object's share() method instead. See
"share method" on page 160.
Syntax
resource.accessControlList.add(principal,level);
level String Determines how the user or group can access the resource or scenario. This can be
one of the following values:
l For scenarios: "View" or "Modify"
l For other resources: "View", "Modify", or "Full".
The "Modify" and "Full" access levels for resources map to the "Author" and
"Manage" sharing options, and should only be assigned to users or groups with
permission to create that resource type. If the user or group does not have
permission to create the resource, they are shown with the access level assigned, but
are unable to modify the resource. The "View" access level maps to either the "Run",
"Open", or "Use" sharing option, depending on the resource type.
For information about sharing resources, see the Maestro Resource Authoring Guide
(Java client)
Returns
No return value.
Exceptions
The add method can throw the following exceptions.
Exception Description
ArgumentError An invalid or null value was specified for a parameter.
AccessControl.InvalidPermissionLevel A value other than "View" or "Modify" was specified for the level
parameter.
ResourceType.NonUniqueName A shared resource or scenario with the same name as the one you are
sharing already exists.
The ResourceType depends on the type of resource you are sharing. If you are sharing a scenario,
the NonUniqueName exception is Scenario.NonUniqueName.
Example
To share a scenario:
To share a workbook to allow the Forecast Planning group to open it and a chart author user to
manage it:
Principal objects
Principal objects represent users and groups. The Principal object has the following properties.
isGroup Boolean Determines whether the principal is a group. For more information, see "Group
object" on page 516.
The permissions property refers to the PermissionCollection object, which contains the following
methods.
Method Description
allow(permissionId) Adds a permission to a user or group.
allow method
The allow method adds a permission to a user or group.
If the principal inherits the permission or if an ancestor group denies the permission, the
permission is not added. If the principle is denied the permission directly, the denial is removed
and the permission is added.
Syntax
principal.permissions.allow(permissionId);
Returns
Type Description
Object A PermissionCollection object.
No return value.
Exceptions
Exception Description
Permission.NotFound The permission ID does not exist.
Examples
This example allows the user with the user ID "jsmith" to author forms.
rapidResponse.users["jsmith"].permissions.allow("AuthorForms");
This example allows the user with the user ID "jsmith" to author and share forms.
rapidResponse.groups["Buyers"].permissions.allow("AuthorWorkbooks");
Note: You can use this method to assign data administration (DataAdministration) or
user administration (UserAdministration) permissions only if you are a system
administrator.
deny method
The deny method removes a permission from a user or group.
The permission is removed if the principal has the permission directly or through group
membership. If the principal does not have the permission already, no change is made.
Syntax
principal.permissions.deny(permissionId);
Returns
Type Description
Object A PermissionCollection object.
Exceptions
Exception Description
Permission.NotFound The permission ID does not exist.
rapidResponse.users["jsmith"].permissions.deny("AuthorForms");
hasPermission method
The hasPermission method determines if a user or group has the specified permission.
Syntax
principal.permissions.hasPermission(permissionId);
Returns
Type Description
Boolean l true if the user or group has the permission
l false if the user or group does not have the
permission
Exceptions
Exception Description
Permission.NotFound The permission ID does not exist.
Example
This example determines if the Buyers group has permission to author workbooks.
rapidResponse.groups["Buyers"].permissions.hasPermission("AuthorWorkbooks");
hasPermission Boolean Whether the user or group has the specified permission.
isInherited Boolean Whether the user or group has inherited the permission or the permission denial.
The following is a list of all permission IDs that can be used with the allow, deny, and
hasPermission methods.
Script objects allow you to use methods from other scripts or call other scripts. Script objects
available to the script are contained in the scripts collection. For more information, see "scripts
collection" on page 130.
Script objects contain the same properties as Resource objects.
For more information about using functions from other scripts, see "Call a function from an
included script" on page 71.
scripts collection
The scripts collection defines all scripts available to the user running the script. Any script
retrieved or called by the script must be present in this collection.
The scripts collection implements the following resource collection methods.
Method Description
get(key) Retrieves an instance of a script object.
exists(script) Determines whether a script with the specified name exists in the collection.
Syntax
aScript = rapidResponse.scripts.get({name:"name", scope:"Public or
Private"});
scope String Whether the script is Public or Private. For more information, see "Using resources as
objects" on page 57.
You can also retrieve the script using its id property, if you know it or can access it.
aScript = rapidResponse.scripts.get(id);
where id is a string that contains the script's id property, which is a GUID consisting of upper
and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
Type Description
Object A script object
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
Example
exists method
Determines whether a script exists. However, because Maestro supports multiple users working
with the same resources, a user might delete the specified script after this method runs. If you
are using this method to test whether a script exists, you should still catch a NotFound exception
for the script you are using.
Syntax
scriptExists = rapidResponse.scripts.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the script exists
l false if the script does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
remove method
Deletes a script from the server, which also removes it from the scripts collection. Deleted
scripts are no longer available to any user or process, and you can only delete scripts you own or
have permission to manage.
Syntax
rapidResponse.scripts.remove( {name: 'scriptName', scope: 'Public or
Private'} );
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Script.NoPermission You do not have permission to delete the specified script.
Example
rapidResponse.scripts.remove({name:"Obsolete_Manage Scenarios",
scope:"Public"});
Method Description
give Changes the owner of a script.
(newOwner)
makePublic() Changes the scope of a script to "Public", which is the equivalent of sharing the script. Public
scripts can be accessed by administrators and users or groups who have been given access to the
script.
You can also share a script with a particular user or group using the accessControlList collection's
add method.
Method Description
call(args) Runs a script with the specified argument values.
give method
Gives a script to another user by changing the script's owner. You can give any script you own.
If the script is shared with other users, you can still access it after giving it. However, if the script
is private, you cannot access it after you give it.
Syntax
script.give(newOwner);
Exceptions
The give method can throw the following exceptions.
Exception Description
Script.NotFound The specified script does not exist.
Script.NonUniqueName The specified user already owns a script with the same name as the one you are
giving.
Example
makePublic method
Changes the scope of the specified script from "Private" to "Public", which shares the script and
allows other users to access it. This method does not specify other users or groups to share the
script with, so it is available to only you and administrators.
If you call this method on a variable that represents a script, you must ensure you assign the
returned public script to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the script with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared script, and you can allow other users and groups to access
a shared script.
Syntax
publicScript = script.makePublic();
Exceptions
The makePublic method can throw the following exceptions
Exception Description
Script.NotFound The specified script does not exist.
Script.NonUniqueName A shared script with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a script. You can rename only private scripts that you own.
Syntax
script.rename(newName);
Returns
No return value.
Exceptions
The rename method can throw the following exceptions.
Script.NameValidationError Either a script with the same name already exists or the specified name is not valid.
Script.NoPermission The script cannot be renamed or you do not have permission to rename it.
Example
copy method
Creates a new private script by copying an existing script. If you copy a shared script, the copy is
private.
If the script you are copying has dependencies, the new script has the same dependencies.
Syntax
script.copy(newName);
Returns
No return value.
Exceptions
The copy method can throw the following exceptions.
Script.NameValidationError Either a script with the same name already exists or the specified name is not valid.
Script.NoPermission The script cannot be copied or you do not have permission to copy it.
Example
call method
Calls a script, which runs the script and, if applicable, returns a value that you can use in your
script. If the called script contains unhandled errors, your script stops running and the line
number where the error occurred is reported in the console output in the script log. See "Script
logging" on page 94.
Syntax
scriptObject.call(args);
Returns
The return value of the called script.
Exceptions
The call method can throw the following exceptions.
Script.IncludeDependency.NotFound An included dependent script does not exist or you do not have access
to it.
Script.Dependency.NotFound A dependency required by the called script does not exist or you do not
have access to it.
Script.CompilationError The called script or one of its dependencies contains syntax errors.
Script.CallDepthExceeded More than 10 nested script calls are made by calling the script.
Example
Scenario objects allow you to compare data or store historical data. Scenario objects are
contained in the scenarios collection. For more information, see "scenarios collection" on page
143.
Scenario objects have the same properties as Resource objects, as well as the following
properties.
activityLog Object Used to record activities performed on the scenario. For more
information, see "ActivityLog objects" on page 142.
childScenarios Object Scenarios that are children of this scenario. This property is a collection of
Scenario objects, and can be empty if the scenario has no children. Child
scenarios can be accessed using the scenario collection methods
described in "scenarios collection" on page 143.
isAutoUpdate Boolean Whether the scenario automatically updates when its parent is modified.
This property can be modified using the setProperties method.
lastCommittedDate Date When changes in the scenario were last committed to its parent.
scopedName String The scope and name of the scenario. The scope identifies if the scenario is
shared or private.
status String The scenario's status. This property can contain one of the following
values:
l InProgress: The scenario's course of action is ongoing.
l Suspended: The scenario's course of action is paused, and
might be resumed later.
l Canceled: The scenario's course of action has been canceled.
l Completed: The scenario's course of action has been
completed.
suppressEditWarning Boolean Whether to suppress or display a warning message to users when they
edit a shared scenario.
usersWithOpenQueries Object The users who have open queries on the scenario. This property contains
a user collection. For more information, see "users collection" on page
504.
isInherited Boolean Whether the scenario inherits the perspective from its parent.
ActivityLog objects
The ActivityLog object that is associated with a scenario is used to record the activity performed
on the scenario. It contains the following properties.
notifyAll Boolean Whether all people with access to the scenario are notified.
Method Description
addResponse(message) Adds a message to the scenario's activity log.
scenarios collection
The scenarios collection contains all scenarios available to the user running the script. Any
scenario retrieved or used by the script must be present in this collection.
The scenarios collection has the following properties:
systemRootScenario Object The root scenario, typically named Enterprise Data. If you do not
have access to this scenario, this value is undefined.
Method Description
create(name, parent, options) Creates a scenario with the specified name and creation options.
Method Description
createTemporary Creates a temporary scenario as a child of the specified parent. The temporary scenario's
(parent) name is automatically generated.
Syntax
aScenario = rapidResponse.scenarios.get({name:"name", scope:"Public or
Private"});
scope String Whether the scenario is Public or Private. For more information, see "Using resources
as objects" on page 57.
Note: The term "public" is used for shared scenarios in scripting because, in earlier
versions, scenarios were referred to as private and public, rather than private and shared.
"Public" is retained in reference to scenario scope to avoid breaking users' scripts.
where SequenceNumber or Id is a string containing the unique number that identifies the
scenario. Each scenario has a sequence number and an Id value that are the same, and which are
unique across your Maestro environment. This number increments every time a scenario is
created. For more information about scenario sequence numbers, see "Obtaining scenario
sequence numbers" on page 153.
Returns
Type Description
Object A scenario object
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
exists method
Determines whether a scenario exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified scenario after this method
runs. If you are using this method to test whether a scenario exists, you should still catch a
NotFound exception.
Syntax
scenarioExists = rapidResponse.scenarios.exists({name: "Name", scope:
"Public or Private"});
Note: The term "public" is used for shared scenarios in scripting because, in earlier
versions, scenarios were referred to as private and public, rather than private and shared.
"Public" is retained in reference to scenario scope to avoid breaking users' scripts.
where SequenceNumber is the unique number that identifies the scenario. Each scenario has a
sequence number, which is unique across your Maestro environment and increments every time
a scenario is created. For more information about scenario sequence numbers, see "Obtaining
scenario sequence numbers" on page 153.
Type Description
Boolean l true if the scenario exists
l false if the scenario does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
create method
This method is used to create a scenario. You must specify the scenario this scenario is based on.
By default, this creates a private scenario. However, some of the options you can specify for the
new scenario are not applicable to a private scenario. If you use these settings, the scenario is
automatically created as a shared scenario.
Syntax
rapidResponse.scenarios.create (name, parentScenario, {creationOptions});
parentScenario Object A Scenario object that represents the new scenario's parent.
The parentScenario can also be identified using its sequence number, as described in "get
method" on page 144.
Returns
No return value.
Exceptions
The create method can throw the following exceptions.
Exception Description
ArgumentError The specified scenario name is not valid, or no parent scenario is specified.
Scenario.NameValidationError Either a scenario with the same name already exists or the specified name is not
valid.
ScenariosLimitExceeded The limit of scenarios has been reached, and would be exceeded if this scenario
is created.
Examples
This example creates a private scenario based on the Enterprise Data scenario.
This example creates a scenario that is updated automatically and contains a purpose. Because
the automatic update setting can apply only to a shared scenario, the new scenario is shared.
This example creates a private scenario that has the Capable perspective applied.
This example creates a shared, permanent scenario and shares it with the Buyers group.
remove method
Deletes a scenario. You can delete only scenarios that you own, and you must own all the
scenario's children. In addition, you cannot delete a scenario if it is in use, such as in a workbook.
The remove method uses an optional Options object, which defines properties that determine
how the scenario is handled during the remove operation. The Options object contains the
following properties.
failIfScenarioHasOpenQueries Boolean Whether the remove fails if there are queries running on the
scenario.
Default value: true
Syntax
rapidResponse.scenarios.remove(scenario, [options])
options Object An optional Options object that defines how the scenario removal is handled.
where SequenceNumber is the unique number that identifies the scenario. Each scenario has a
sequence number, which is unique across your Maestro environment and increments every time
a scenario is created. For more information about scenario sequence numbers, see "Obtaining
scenario sequence numbers" on page 153.
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Scenario.NoPermission Either you do not have permission to delete the specified scenario or
the scenario is a change data capture scenario and cannot be
removed.
Examples
This example removes a scenario.
This example removes a scenario, but fails if the scenario has children.
This example removes a scenario, even if queries are running on it, but fails if the scenario has
children.
createTemporary method
Creates a temporary scenario. Temporary scenarios are created with an automatically-generated
name, and cannot be shared.
Syntax
rapidResponse.scenarios.createTemporary(parent);
Returns
A Scenario object with its type property set to Temporary.
Exceptions
The createTemporary method can throw the following exceptions.
Exception Description
ArgumentError The specified scenario name is not valid, or no parent scenario is specified.
Example
Note: Temporary scenarios are not affected by the scenario limits on groups, and can
always be created as part of a process that requires them.
createWorkflowScenario method
This method is used to create a scenario within a workflow. It gets an scenario, for example the
Process Orchestration scenario, and using the workflow execution ID it runs a script to create a
new child scenario.
Syntax
rapidResponse.scenarios.createWorkflowScenario (workflowExecutionId,
parentScenario [, perspective]);
parentScenario String The parent scenario of the scenario created by this method.
perspective String The perspective applied to the scenario. This parameter is optional.
Note: This method can created an unlimited number of scenarios using the same
workflowExecutionId, however only a maximum of 20 scenarios can exist in a workflow. It
is recommended that the workflow manage these scenarios by committing and/or
deleting them accordingly to keep within the 20 scenario limit.
Returns
A new child scenario of the specified parent scenario. This child scenario is private in scope and
hidden.
Exceptions
The createWorkflowScenario method can throw the following exceptions.
Exception Description
ArgumentError The specified workflow instance identifier is not valid, or the parent scenario is
not specified.
Scenario.TooManyScenarios The limit of 20 scenarios has been reached in the workflow, and would be
exceeded if this scenario is created.
Example
You can also determine the sequence number by reading the value from a worksheet that has
been configured to display the sequence number for a specified scenario. The Maestro query
language includes functions to access scenario properties that are not otherwise exposed. The
worksheet must use these functions to return the sequence number:
l CanonicalScenarioId: Takes the scenario and its owner, and returns an identifier for the
scenario.
l ScenarioProperty: Takes the canonical scenario identifier and returns a String value that can
report the scenario's name, type, owner, or sequence number.
where $scen and $user are variables that define the scenario and user who owns it. An example
of a column using this expression is shown in the following.
You can also create a workbook that uses the RapidResponse System Data workbook as a
reference, and create a worksheet that contains the Sequence Number column.
Depending on how you need to use the scenario, you can pass the sequence number or id
property to other called scripts or pass them to a function if you need to use the same scenario
in multiple places within the script. Retrieving scenarios by id can simplify the usage, because
you do not need to pass the name and scope, just the id. The id and sequence number do not
change if you share or rename the scenario.
makePublic() Changes the scope of a scenario to "Public", which is the equivalent of sharing the scenario.
Shared scenarios can be accessed by administrators and users and groups with access.
You can also share a scenario with a particular user or group using the accessControlList
collection's add method.
Note: The term "public" is used for shared scenarios in scripting because, in earlier versions,
scenarios were referred to as private and public, rather than private and shared. "Public" is
retained in reference to scenario scope to avoid breaking users' scripts.
Method Description
share() Shares the scenario with a specified list of users or groups.
update() Updates the scenario with changes from its parent. If the scenario automatically updates, you do
not have to call this method.
reset() Discards all changes in a scenario, and sets its data to be identical to its parent.
give method
Gives a scenario to another user by changing the scenario's owner. You can give any scenario
you own.
After you give the scenario, you can no longer access it. If you require access to the scenario after
you give it, you must share it with yourself before calling this method. For more information, see
"accessControlList collection" on page 119.
Syntax
scenario.give(newOwner);
Returns
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Scenario.NotFound The specified scenario does not exist.
Scenario.NoPermission Either you do not have permission to give the scenario, or the scenario is a
temporary or change data capture scenario and cannot be given.
Scenario.NonUniqueName The new owner already owns a private scenario with the same name.
Scenario.Give.OverScenarioLimit The new owner has reached their scenario limit and cannot be given
additional scenarios. This exception can also be thrown if the scenario you
give has children, and one of the children causes the user to exceed the
scenario limit.
Example
This example creates a scenario, shares it with the user running the script, and then gives it to
another user.
makePublic method
Changes the scope of the specified scenario from "Private" to "Public", which shares the scenario
and allows other users to access it. This method does not specify other users or groups to share
the scenario with, so it is available to only you and administrators.
If you call this method on a variable that represents a scenario, you must ensure you assign the
returned shared scenario to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the scenario with specific users and groups using the accessControlList
collection's add method. You can also use the Scenario object's share method for sharing
scenarios.
Administrators can access any shared scenario, and you can allow other users and groups to
access a shared scenario.
Syntax
publicScenario = scenario.makePublic();
Returns
A Scenario object that represents the same scenario with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions
Scenario.NoPermission Either you do not have permission to share the scenario, or the scenario is a
temporary or change data capture scenario and cannot be shared.
Example
Note: The term "public" is used for shared scenarios in scripting because, in earlier
versions, scenarios were referred to as private and public, rather than private and shared.
"Public" is retained in reference to scenario scope to avoid breaking users' scripts.
rename method
Changes the name of a scenario. You can rename private and shared scenarios that you own.
This differs from the Maestro client where you can only rename private scenarios that you own.
Syntax
scenario.rename(newName, failIfScenarioHasOpenQueries);
failIfScenarioHasOpenQueries Boolean An optional parameter that defines whether the rename operation
fails if queries are running on the scenario.
Returns
No return value.
Exceptions
The rename method can throw the following exceptions.
Scenario.NameValidationError Either a scenario with the same name already exists or the specified name is not
valid.
Scenario.NoPermission Either you do not have permission to rename the scenario or the scenario is a
temporary or change data capture scenario and cannot be renamed.
Scenario.HasOpenQueries The scenario has queries running on it, or is being used in a workbook or
scorecard.
Example
This example renames a scenario.
This example renames a scenario, but fails if any queries are running on that scenario
share method
Shares a specified scenario with the users or groups you specify. Each user or group requires a
scenario permission level, which you also specify in the method call.
This method can be used to share an already shared scenario with additional users, or can make
a private scenario shared. You can use this method instead of the makePublic and
accessControlList.add methods for sharing a private scenario.
where
principalLevels String An array of permission levels to assign to each principal. These must be defined
array in the same order as the principalIds array.
Valid values for this array are "View" and "Modify".
isStartSOPCycle Boolean Optionally, whether this scenario represents the start of an S&OP cycle. This
value should typically be false.
Default is false.
Note: The list of principals to share the scenario with is not validated, so any invalid
users or groups are ignored.
Returns
The scenario that was shared, represented as an object with the {name, scope} syntax.
Exceptions
The share method does not throw exceptions
Example
This example shares a newly-created scenario with the Buyers group.
newScen.share({
principalIds: ['Buyers'],
principalLevels: ['View']
});
This example shares a scenario specified as a script argument with a set of users and groups.
toShare.share({
principalIds: ['jlarson', 'mdeng', 'Operations'],
principalLevels: ['View', 'Modify','View']
});
update method
Updates a scenario with data changes from its parent.
Syntax
updateScenario = updateScenario.update();
Returns
Type Description
Object The updated scenario object
Exceptions
The update method can throw the following exceptions.
Exception Description
Scenario.NoPermission Either you do not have permission to update the specified scenario or the scenario is a
change data capture scenario and cannot be updated.
Scenario.NeedsReset The scenario's parent has been reset, so the scenario being updated must be reset as
well. For more information, see "reset method" on page 163.
Example
reset method
Resets a scenario, making its data the same as its parent.
Syntax
resetScenario.reset();
where resetScenario is a scenario object.
Returns
No return value.
Exceptions
The reset method can throw the following exceptions.
Exception Description
Scenario.NoPermission Either you do not have permission to reset the specified scenario or the scenario is a
change data capture scenario and cannot be reset.
Scenario.NonRootOnly The specified scenario is the root scenario, which cannot be reset.
Example
commit method
Commits data changes from a scenario into its parent. You can commit any scenario you own, as
long as you own or have permission to modify its parent scenario and the scenario is up to date.
If the scenario you are committing has children, you can specify how those scenarios are
Returns
Type Description
Object The committed scenario object
Exceptions
The commit method can throw the following exceptions.
Exception Description
Scenario.NoPermission Either you do not have permission to commit the specified scenario or the scenario
is a change data capture scenario and cannot be committed.
Scenario.NeedsUpdate The scenario is out of date with its parent and needs to be updated before it can be
committed. This exception is not thrown if the Options.forceUpdate parameter
is set to true.
Scenario.NonRootOnly The specified scenario is the root scenario, which cannot be committed.
Scenario.HasOpenQueries The scenario has queries running on it, or is being used in a workbook or scorecard.
Examples
The following example commits a scenario and forces it to update.
The following example commits a scenario and forces it to update, but fails if the scenario has
children.
The following example commits a scenario, using the forceUpdate argument on the commit()
method.
addResponse method
Adds a message to the scenario's activity log.
Syntax
Scenario.activityLog.addResponse( {subject, type, body, notifyAll} );
where Scenario is a Scenario object.
type String The type of activity being logged. This can be one of the following values:
l Note: The response contains information about the activity performed.
l Accept: For collaboration, indicates the proposed changes can proceed.
l Reject: For collaboration, indicates the proposed changes cannot
proceed.
This parameter is optional. If no value is provided, "Note" is used.
notifyAll Boolean Indicates whether all users with access to the scenario are notified about the
changes.
This parameter is optional. If no value is provided, false is used.
Return value
No return value.
Exceptions
The addResponse method does not throw exceptions.
Examples
This example notifies all users of a change accepted in the Enterprise Data scenario.
rapidResponse.scenarios.systemRootScenario.activityLog.addResponse( {
subject: "Accept Change",
type: "Accept",
body: "All changes accepted.",
notifyAll: true
} );
This example records a note about the changes performed by a workbook command.
setProperties method
Specifies values for scenario properties. This method allows you to modify the specified property
values after retrieving a Scenario object.
If you specify values for multiple properties in a single call, the method succeeds only if all
properties are set successfully. If any property cannot be set, the method fails and no values are
changed.
Syntax
scenario.setProperties( {permanent, autoUpdate, purpose, status} );
where scenario is a Scenario object.
autoUpdate Boolean Whether the scenario automatically updates when its parent is modified.
status String The scenario's status. This is typically used for scenarios that contain collaboration
exercises, and can be one of the following values:
l InProgress: The scenario's course of action is ongoing.
l Suspended: The scenario's course of action is paused, and might be
resumed later.
l Canceled: The scenario's course of action has been canceled.
l Completed: The scenario's course of action has been completed.
Return value
No return value.
Exceptions
The setProperties method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter.
Scenario.ParentNotPermanent The scenario's parent is not permanent and a True value was passed to the
permanent parameter.
Examples
This example designates a scenario's course of action as complete, and disables automatic
updates. This ensures the data is not modified as it is reviewed before being committed.
This example designates a scenario as permanent, and updates its purpose to indicate when it
was made permanent.
getPriority method
Retrieves the caching priority specified for a permanent scenario.
Syntax
var scenarioPriority = Scenario.getPriority();
Return value
An integer representing the priority set for the scenario.
Exceptions
The getPriority method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter.
Scenario.Notfound The scenario does not exist or you do not have access to it.
Example
The following example retrieves the priority specified for the Baseline scenario
setPriority method
Sets the caching priority specified for a permanent scenario you have access to. This can be used
in external processes to ensure only scenarios with certain priority levels are cached. This
method is available only to administrators.
If you are using the Command and Control Center (CCC) application, you cannot call this method
on the Process Orchestration scenario. For more information about CCC, see the Maestro
Applications Guide (Java client) or the Maestro Applications Guide (Web client).
Syntax
Scenario.setPriority(priority);
Return value
No return value.
Exceptions
The setPriority method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter, or an invalid negative or non-integer priority
value was provided.
Scenario.Notfound The scenario does not exist or you do not have access to it.
Example
The following example sets the priority for the Baseline scenario to 5.
cdcInstances collection
All change data capture (CDC) instances defined on a scenario are contained in the cdcInstances
collection. Each instance is available to a single user.
The cdcInstances collection implements the following method.
Method Description
get(instance) Retrieves the specified CDC instance.
get method
Retrieves a change data capture (CDC) instance, which you can use to capture and send data
changes to an external system.
Syntax
inst = scenario.cdcInstances.get(instanceID);
where scenario is a Scenario object.
Returns
A CDCInstance object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
CDCInstance objects
The CDCInstance object defines a Change Data Capture (CDC) instance that monitors a scenario
for data changes. The instance maintains the changes made in the monitored scenario, and
allows you to retrieve the changes for synchronizing data changes between systems. All CDC
instances you have access to are contained in the cdcInstances collection. For more
information, see "cdcInstances collection" on page 172.
The CDCInstance object has the following property.
Method Description
captureChanges() Retrieves all changes made in the scenario since the instance was last cleared.
clearChanges() Clears all captured changes from the instance, which ensures changes are not captured
multiple times.
resetChanges() Resets the instance, which clears all changes whether they have been captured or not.
For more information about CDC, see the Maestro Web Services Guide.
captureChanges method
The captureChanges method retrieves all changes from a change data capture (CDC) instance.
Syntax
instance.captureChanges();
where instance is a CDCInstance object.
Returns
No return value.
Exception Description
ArgumentError An argument was passed to the method.
Example
clearChanges method
Clears all captured changes from a change data capture (CDC) instance. Calling this method
ensures the changes that have been captured are not captured again, preventing double
reporting.
Changes made in the scenario between the time when the changes were captured and when
they were cleared are captured the next time the captureChanges method is called. For more
information, see "captureChanges method" on page 173.
Syntax
instance.clearChanges();
Returns
No return value.
Exceptions
The clearChanges method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
resetChanges method
Clears all changes from a change data capture (CDC) instance and resets the instance so only
changes made after the reset are captured. This method should typically be called when a course
of action has been reverted, so those changes are not captured. For more information about
capturing changes, see "captureChanges method" on page 173.
Syntax
instance.resetChanges();
where instance is a CDCInstance object.
Returns
No return value.
Exceptions
The resetChanges method can throw the following exceptions.
Exception Description
ArgumentError An argument was passed to the method.
Example
Workbook objects can be used to run commands, and contain worksheets that can be used to
retrieve data. Workbook objects are contained in the workbooks collection. For more
information, see "workbooks collection" on page 179.
Workbook objects have the same properties as Resource objects, as well as the following
properties.
dependencies Object A collection of workbooks that this workbook depends on for functionality. This
collection is empty if the workbook does not have dependencies. For more
information, see "dependencies collection" on page 195.
The Workbook object also uses a WorkbookInitialization object, which defines the resources
used to define the data returned by the worksheet queries. The properties of this object
determine the resources used for the entire workbook. However, you can also specify resources
individually for each worksheet. If you do not specify values for each worksheet, the values for
the workbook are used. The WorkbookInitialization object has the following properties.
filter Object The filter used with the workbook, identified as either a Filter object or by using
the {name, scope} syntax.
siteGroup Object The site or site filter used with the workbook, identified as either a SiteGroup
object or by using the {name, scope} syntax. Individual sites are always public.
hierarchies Object The hierarchy or hierarchies applied to the workbook, and the values selected
within them. This value is an array of hierarchies.
variables Object An array of variables defined in the workbook. Values must be provided for each
variable defined in this property. For list variables, you must specify the list entry's
display value.
The values specified in this property when the workbook is retrieved are the only
values that can be set for the variables. If you want to modify a variable's value,
you must retrieve another copy of the workbook. For more information, see "get
method" on page 180.
currency String The currency used to display Money values in the workbook. This must be a
currency code that has been defined in your Maestro instance, such as USD or
EUR.
partType String The part type selected in the workbook. This value can be "Parts" or Reference
Parts".
part String The part selected in the workbook. This value is relevant if the partType value is
"Parts".
referencePart String The reference part selected in the workbook. This value is relevant if the partType
value is "Reference Parts".
cdcInstance Object The change data capture (CDC) instance that monitors the workbook for changes.
This property is undefined for workbooks that are not used for CDC. For CDC
workbooks, this property is used instead of the scenario property. For more
information, see "CDCInstance objects" on page 173.
Values for the WorkbookInitialization object's properties can be specified as the workbook's
filter settings when you retrieve a workbook from the workbooks collection. These values cannot
be modified after retrieving the workbook. For more information, see "get method" on page 180.
The hierarchies property refers to a WorkbookHierarchyInitialization object, which has the
following properties.
path Object The values selected in the hierarchy. This property includes the names of the hierarchy
values and optionally, values selected in levels underneath the current level.
childPath Object The values selected in the level below the current level. The childPath property is a
path object, so each childPath can have its own childPath, until the last level of the
hierarchy is reached. The last level of the hierarchy has a blank value for its childPath.
The variables property of the workbook initialization object refers to an object that has the
following properties.
For more information about workbook variables, see the Maestro Resource Authoring Guide (Java
client).
A Workbook object can be used to generate a report of worksheet data, which is stored in a
ReportOutput object. The ReportOutput object does not contain properties, and can be included
in a message. For more information, see "messages collection" on page 498.
WorkbookPreferences objects
The WorkbookPrefences object contains your personal resource preferences. This object
contains no properties or methods, but can be used to pass your preferences from a dashboard
to a workbook, or from a worksheet to a filter manager object. For more information, see
"FilterManager object" on page 267.
workbooks collection
The workbooks collection contains all workbooks available to the user running the script. Any
workbook retrieved or used by the script must be present in this collection
The workbooks collection implements the following resource collection methods.
Method Description
get(key, options) Retrieves the specified workbook using the specified filtering options.
Syntax
rapidResponse.workbooks.get( {name:"Name", scope:"Public or Private"},
{initialization} );
scope String Whether the workbook is Private or Public. For more information, see "Using
resources as objects" on page 57.
initialization Object An optional set of options that determine the data displayed in the workbook. The
properties you can specify are contained in the WorkbookInitialization object of the
Workbook object. For information about the properties you can specify, see
"Workbook objects" on page 176.
You can also use the workbook's identifier within the workbooks collection instead of the
{name, scope} syntax. This is typically used for retrieving workbooks in a resource iteration
function, such as the forEach or forEachId functions. For more information, see "Resource
collections" on page 107. You can also use the identifier if you want to retrieve the same
workbook with different settings.
aWorkbook = rapidResponse.workbooks.get(id, {initialization});
where id is a string that contains the workbook's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}. If you are retrieving the
same workbook with different settings, you can use a variable to hold the id value.
Returns
Type Description
Object A workbook object
Exceptions
The get method can throw the following exceptions.
CDCInstance.NotFound The specified change data capture instance does not exist.
Example
Retrieving a workbook.
Retrieving a workbook that displays data for a specific model of a part, with monetary values
displayed in Euros.
Retrieving a workbook that displays part or reference part data, depending on what is specified
in the worksheet the script is called from.
Retrieving a workbook that uses a filter expression in a variable for its worksheets. For the
worksheetFilterExpression variable, the worksheet's filter expression must use the EVAL function
to evaluate the expression contained in the variable. For more information, see the Maestro
Resource Authoring Guide (Java client).
var workbookSettings = {
scenarios: [{ name:"myScenario", scope:"Private" }],
filter: {name: "Buy Parts", scope:"Public"},
siteGroup: {name: "DC-Asia", scope: "Public"},
pool: "Unpooled",
variables: [
{name: "showLate", value: true},
{name: "onDate", value: rapidResponse.dateTime.TODAY}
],
currency:"USD"
exists method
Determines whether a workbook exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified workbook after this method
Syntax
workbookExists = rapidResponse.workbooks.exists({name: "Name", scope:
"Public or Private"});
Returns
Type Description
Boolean l true if the workbook exists
l false if the workbook does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
remove method
Deletes a workbook from the server, which also removes it from the workbooks collection.
Deleted workbooks are no longer available to any user or process, and you can only delete
workbooks you own or have permission to manage.
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Workbook.NoPermission You do not have permission to delete the specified workbook.
Example
Method Description
give Gives the workbook to the specified user.
(newOwner)
makePublic() Changes the scope of a workbook to "Public", which is the equivalent of sharing the workbook.
Public workbookscan be accessed by administrators and users and groups with access.
You can also share a workbook with a particular user or group using the accessControlList
collection's add method.
Method Description
generateReport(worksheet, format, Creates a report of data in the workbook, using the options you
options) specify.
give method
Gives a workbook to the specified user.
Syntax
workbook.give(newOwner);
where workbook is a Workbook object.
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Workbook.NotFound The specified workbook does not exist.
Workbook.NonUniqueName The specified user already owns a workbook with the same name as the one you
are giving.
Example
makePublic method
Changes the scope of the specified workbook from "Private" to "Public", which shares the
workbook and allows other users to access it. This method does not specify other users or
groups to share the workbook with, so it is available to only you and administrators.
If you call this method on a variable that represents a workbook, you must ensure you assign the
returned public workbook to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the workbook with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared workbook, and you can allow other users and groups to
access a shared workbook.
Syntax
publicWorkbook = workbook.makePublic();
where workbook is a Workbook object.
Return value
A Workbook object that represents the same workbook with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
Workbook.NotFound The specified workbook does not exist.
Workbook.NonUniqueName A shared workbook with the same name as the one you are sharing already
exists.
rename method
Changes the name of a workbook.
Syntax
workbook.rename(newName);
where workbook is a Workbook object.
Return value
No return value.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Workbook.NameValidationError Either a workbook with the same name already exists or the specified name is
not valid.
Workbook.NoPermission The workbook cannot be renamed or you do not have permission to rename
it.
copy method
Creates a new workbook by copying an existing workbook. If you copy a public workbook, the
copy is private.
Syntax
workbook.copy(newName);
where workbook is a Workbook object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Workbook.NameValidationError Either a workbook with the same name already exists or the specified name is
not valid.
Workbook.NoPermission The workbook cannot be copied or you do not have permission to copy it.
generateReport method
Creates a report of the data contained in a worksheet. You can specify the file format used to
create the report, and options for formatting the data.
Syntax
report = workbook.generateReport( worksheet, format, {encoding,
formatHiddenDuplicates, includeColumnHeaders, includeFormatting} );
where workbook is a Workbook object.
format String The file format of the report. This can be one of the following values:
l XLSX: A Microsoft Excel file (versions 2007-2019), which can
be viewed in Microsoft Excel.
l PDF: A PDF file, which can be viewed in any PDF reader, such
as Adobe Reader.
l HTML: A web page, which can be viewed in a web browser.
l XML: An XML file, which can be viewed in a web browser or
word processor.
l TAB: A tab-delimited tab file, which can be viewed in a word
processor.
l excelTemplate: If the workbook uses a report template,
exports the data defined by that template. This option must
be used with a single worksheet.
formatHiddenDuplicates String Defines how hidden duplicate values in the worksheet are shown in the
report. This can be one of the following values:
l Show: Displays all duplicate values.
l Hide: Hides duplicate values in the report.
l Clear: Deletes duplicate values from the report.
This parameter is optional. If a value is not provided, the following
values are used for each format:
l XLSX: Hide
l PDF: Hide
l HTML: Hide
l XML: Show
l TAB: Show
includeFormatting Boolean Indicates whether the worksheet's formats (colors, text formatting,
fonts, and so on) are preserved in the report. This parameter applies to
Microsoft Excel reports.
This parameter is optional. If a value is not provided but is relevant, the
"True" value is used. following values are used:
Return value
A ReportOutput object.
Exceptions
The generateReport method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed for a parameter or a required parameter is
missing.
Workbook.Report.ExceededExcelLimit The worksheet results in more than 1048576 rows for an XLSX report.
Examples
This example generates a single worksheet report as an HTML file.
This example generates a report of all worksheets in the workbook as an XLSX file and then
sends it to the Production Planners group.
This example generates a report using the workbook's report template and sends it to the
Production Planners group.
dependencies collection
The dependencies collection contains all workbooks that a workbook depends on, represented
as WorkbookDependency objects.
The dependencies collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
WorkbookDependency objects
WorkbookDependency objects define workbooks that another workbook depends on for
functionality. The WorkbookDependency object has the following properties.
variables collection
The variables collection contains all workbook variables defined in a workbook, represented as
WorkbookVariable objects.
The variables collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
defaultType String The default value for the variable. This property must be one of the following:
l DefaultForType: The variable's default value is the default for the
type of variable. For more information about the default values for
variables, see the Maestro Resource Authoring Guide (Java client).
l None: The variable does not have a default value.
l First: For list variables, the default value is the first value in the list.
l Value: The specified value is the default for the variable.
isLabelOnToolbar Boolean Whether the variable's label is displayed on the workbook toolbar.
defaultValue String The value used for the variable if no other value is specified. This property is
required only if the variable takes a default value.
quantityValue Object For quantity variables, contains a VariableValueQuantity object that defines
the value contained in the variable.
booleanValue Object For Boolean variables, contains a VariableValueBoolean object that defines the
value contained in the variable.
listValue Object For list variables, contains a VariableValueList object that defines the list values
contained in the variable.
VariableValueQuantity object
The VariableValueQuantity object defines the minimum and maximum values for a quantity
variable. This object has the following properties.
VariableValueBoolean object
The VariableValueBoolean object defines the true and false values in a Boolean variable. This
object contains the following properties.
falseDisplayValue String The value displayed in resources when the variable is set to false.
trueDataValue String The data value used when the variable is set to true.
trueDisplayValue String The value displayed in resources when the variable is set to true.
VariableValueList object
The VariableValueList object defines the values included in a list variable. List variables define
data values that are used in expressions and display values that users see. All processes that use
list variables must specify the display value.
This object contains the following properties.
query Object A VariableValueListQuery object that defines the query-generated values in the list.
displayValue String The fixed value's display value, which is displayed in the toolbar control or Data
Settings dialog box.
NameValuePair object
The NameValuePair object defines the value stored in a variable. This object contains the
following properties.
commands collection
The commands collection contains the commands defined in a workbook, which are represented
as Command objects.
The commands collection implements the following methods.
Method Description
get(command) Retrieves a Command object from the commands collection.
get method
Retrieves a workbook command.
Syntax
var command = workbook.commands.get(commandName);
Returns
Type Description
Object A Workbook command object
Exceptions
The get method can throw the following exceptions.
Exception Description
Workbook.Command.NotFound The specified workbook command does not exist.
Example
exists method
Determines whether a command exists in a workbook. However, because Maestro supports
multiple users working with the same resources, a user might delete the specified command
after this method runs. If you are using this method to test whether a command exists, you
should still catch a NotFound exception for the command you are using.
Returns
Type Description
Boolean l true if the command exists
l false if the command does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError The parameter is missing a name value.
Examples
Command object
The Command object defines a command in a workbook, which can either modify data in the
workbook or run a script. All commands defined in a workbook are contained in the commands
collection.
The Command object has the following properties.
type String The type of command. This can be one of the following:
l DataUpdate: Performs a data modification using the actions defined in
worksheets.
l Script: Runs a script.
l OpenForm: Opens a form.
DataUpdateCommand object
The DataUpdateCommand object defines a workbook command that inserts, modifies, deletes,
or updates records in worksheets. The DataUpdateCommand object has the following
properties.
The Action object represents one action the command performs, and has the following property.
Method Description
execute() Runs the workbook command.
ScriptCommand object
The ScriptCommand object defines a workbook command that executes a script. The
ScriptCommand object has the following properties.
Method Description
execute() Runs the workbook command.
OpenFormCommand object
The OpenFormCommand object defines a command in a workbook that opens a form. The
OpenFormCommand object has the following properties.
execute method
Runs a workbook command, which performs the data modifications defined in or runs the script
specified in the command.
The execute method can also be called on the actions contained with a data modification
command, which performs the action specified.
Syntax
workbookCommand.execute();
workbookCommand.execute( [function(action)]{result = action.execute();});
result = scriptCommand.execute();
where workbookCommand is a workbook command object that performs a data modification,
and scriptCommand is a workbook command object that runs a script.
Note: For users to successfully run the workbook command in a shared scenario, they
must have permission to edit data in shared scenarios.
Returns
For data modification commands, an object that contains a summary of all actions performed by
the command.
Each action within the command returns an object with the following properties.
The properties populated by this object depend on the type of the data modification. For
example, a data modification of type Delete populates only the deleted property. An Update
data modification can populate all three of the properties, depending on the actions defined in
the data modification. The values for a property not populated by an action are 'undefined'.
For script commands, the script's return value. If the script does not return a value, this method
does not return a value.
Exceptions
The execute method can throw the following exceptions.
Workbook.Command.Scenario.NotSpecified A scenario was not specified when the workbook object was
retrieved. The command requires a scenario to run.
Examples
To run a workbook command:
To execute only one action defined in a workbook command and return the number of records
modified:
Worksheet objects define the worksheets in a workbook, and can be used to perform data
modifications or retrieve data. Worksheet objects are contained in the worksheets collection. For
more information, see "worksheets collection" on page 209.
Worksheet objects have the following properties.
displayName String The name displayed in the workbook for the worksheet.
filter Object The filter applied to the worksheet, identified as either a Filter object or by
using the {name, scope} syntax.
siteGroup Object The site or site filter the worksheet displays data for, identified as either a
SiteGroup object or by using the {name, scope} syntax. Individual sites are
always Public.
partType String The part type selected in the worksheet. This value can be "Parts" or
Reference Parts".
part String The part selected in the worksheet. This value is relevant if the partType value
is "Parts".
referencePart String The reference part selected in the worksheet. This value is relevant if the
partType value is "Reference Parts".
hierarchies Object The hierarchy or hierarchies applied to the worksheet, and the values selected
within them. For more information about how hierarchies are defined in
scripts, see "Workbook objects" on page 176.
variables Object An array of variables used by the worksheet, and the values specified for
them. For more information about how variables are specified, see "variables"
on page 177.
columns Object The columns in the worksheet. For more information, see "WorksheetColumn
object" on page 230.
sortedColumns Object An array of worksheet columns, ordered according to the sort order of the
columns in the worksheet.
dataModification Object The type of data modification defined in the worksheet. For more information,
see "WorksheetDataModification object" on page 238.
importData Object Data that is imported into the worksheet. For more information, see
"Worksheet data import objects" on page 234.
crosstabWorksheet Object The crosstab settings for this worksheet. For more information, see
"CrosstabWorksheet object" on page 208.
autobucketInfo Object The automatically-generated bucket settings for a crosstab worksheet. For
more information, see "AutobucketInfo object" on page 243.
bucketSettings Object Settings and options specified for the worksheet's buckets. For more
information, see "Worksheet bucketing objects" on page 239.
searchColumns Object Search conditions applied to columns in the worksheet. See "Worksheet
searches" on page 209.
CrosstabWorksheet object
The CrosstabWorksheet object defines settings specific to crosstab worksheets. This object
contains the following properties.
bucketColumnId String The identifier of the column used to define the buckets.
Worksheet arguments
For scripts that run from workbook commands, additional arguments are automatically used to
define the workbook (#Workbook), worksheet (#Worksheet), and selected data
(#WorksheetSelection) the script runs on. For information about these arguments, see "Define
arguments for a script" on page 62.
The #WorksheetSelection argument defines an object that contains the rows and cells that the
worksheet user has selected. The selection made in the worksheet determines a set of data that
Property Description
start Defines the first (top left) cell of the selection. This is set by specifying the following:
l rowIndex: The row the selected cell is in. This value is set in relation to the first row in
the worksheet.
l cellIndex: The selected cell. This value is set in relation to the first cell in the rows.
end Defines the last (bottom right) cell of the selection. This is set by specifying the following:
l rowIndex: The row the selected cell is in. This value is set in relation to the first row in
the worksheet.
l cellIndex: The selected cell. This value is set in relation to the first cell in the rows.
These properties define the start and end cells of the selection. The rowIndex and cellIndex
values are taken from the data rows and cells from the worksheet. You can use the start and end
properties as the input to the slice() method to limit the data analysis to only the worksheet
selection.
Worksheet searches
Each worksheet contains an object that defines any search conditions applied to its columns.
This is typically populated only if you are accessing the worksheet using the #Worksheet
argument. The column searches are defined in an object with the following properties:
filterValue String The condition searched for. This can be a constant value or an expression.
worksheets collection
The worksheets collection contains worksheet objects representing each worksheet in a
workbook. Each workbook contains a worksheets collection.
The worksheets collection implements the following resource collection methods.
get method
Retrieves a worksheet object, which allows you to manipulate the worksheet in your script.
Worksheets can be used to run data modifications and retrieve data.
Syntax
workbook.worksheets.get(worksheetId);
Returns
Type Description
Object A worksheet object
Exceptions
The get method can throw the following exceptions.
Exception Description
Worksheet.NotFound The specified worksheet does not exist in the workbook.
Example
exists method
Determines whether a worksheet exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified worksheet after this method
runs. If you are using this method to test whether a worksheet exists, you should still catch a
NotFound exception for the worksheet you are using.
Syntax
worksheetExists = workbook.worksheets.exists(worksheetId);
Returns
Type Description
Boolean l true if the worksheet exists
l false if the worksheet does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError The parameter is missing a name value.
Examples
Method Description
getAvailableHierarchies() Retrieves the valid hierarchies that can be applied to the worksheet.
getChart([height, width]) Retrieves a chart from the worksheet, with the specified dimensions.
getData() Retrieves the data rows and cells from the worksheet.
For more information about rows and cells, see "Worksheet data objects" on page
232.
getFilterManager() Retrieves the filter manager object that contains the worksheet's filter settings.
getPossibleControlValues Displays the valid settings for the specified type of control.
(type, settings)
importData(data) Imports the specified data. For more information about the data to import, see
"Worksheet data import objects" on page 234.
convertToJSON(format, Converts worksheet data to a JSON object that can be sent to other services and
startRow, pageSize) systems.
Method Description
execute() Performs the data modification defined in the worksheet.
Syntax
hierarchies = worksheet.getAvailableHierarchies();
where worksheet is a Worksheet object.
Returns
An array of String values.
Exceptions
The getAvailableHierarchies method does not throw exceptions.
Example
getChart method
Retrieves a chart from a worksheet.
Note: As of Service Update 2510, this method is no longer supported in scripts. Please
contact the script author or Kinaxis Customer Support if you require further assistance.
Syntax
worksheet.getChart([height, width]);
where worksheet is a Worksheet object.
width Number The width of the chart, in pixels. This value must be a positive value less than or
equal to 2880.
Returns
A JsChart object representing the chart.
Exceptions
The getChart method can throw the following exception.
Exception Description
ArgumentException One of the following has occurred.
l A parameter is missing or a null value was passed for a parameter.
l The values passed for the height or width parameters are either not numbers,
are negative, or are greater than the maximum size for the parameter.
Example
getChartDefinition method
Retrieves a chart definition object.
Syntax
chartDefinition = worksheet.getChartDefinition();
Returns
A chart definition object.
Example
getData method
Gets the data from a worksheet. This represents the worksheet data at the moment the method
is called, and is not automatically updated if the data in the worksheet changes. If you want the
data to reflect updates, you must close the worksheet query and then call this method again. For
more information about closing worksheet queries, see "close method" on page 237.
Syntax
worksheetData = worksheet.getData();
filterValue The value to search for. This can be a simple expression that compares the column value to a
constant or other column value, or a variable that defines the value to compare against. If you
specify a constant or a variable, only values that exactly match that value are returned.
Returns
Type Description
Object The worksheet data object that contains the worksheet's data row collection.
Exceptions
The getData method can throw the following exceptions.
Exception Description
Scenario.NotFound The scenario specified for the worksheet does not exist.
Filter.NotFound The filter specified for the worksheet does not exist.
SiteGroup.NotFound The site or site filter specified for the worksheet does not exist.
Model.NotFound The model specified for the worksheet does not exist.
Pool.NotFound The pool specified for the worksheet does not exist.
Example
This example gets data for make parts from the HQ site.
This example gets data for Make parts from the HQ site where the quantity is greater than 2,000.
In this example, the search condition is an expression, which matches the syntax you would use
to search the same column in the worksheet.
This example gets data for Buy parts from the HQ site where the quantity for the comparison
scenario is less than the value for the baseline scenario. This example requires the worksheet to
display differences in the multi-scenario Quantity column.
getFilterManager method
Retrieves the FilterManager object that defines the worksheet's filter settings.
Syntax
worksheetFilter = worksheet.getFilterManager();
where worksheet is a Worksheet object.
Returns
A FilterManager object.
Exceptions
The getFilterManager method does not throw exceptions.
Example
getPossibleControlValues method
Returns all valid options for a worksheet control setting, based on the data settings that are valid
for a widget based on the worksheet.
Syntax
worksheet.getPossibleControlValues(type, controlSettings);
controlSettings Object The ControlSettings object that defines the data displayed in the worksheet.
Returns
An array of objects that are valid for the control values.
Exceptions
The getPossibleControlValues method can throw the following exceptions.
Example
This example lists scenarios that can be used with the worksheet the Monthly Revenue widget is
based on.
getTreemapQuery method
This method retrieves the treemap defined on a worksheet.
Syntax
treemap = worksheet.getTreemapQuery();
where worksheet is a Worksheet object.
Returns
A TreemapQuery object.
Exceptions
The getTreemapQuery method can throw the following exceptions.
Example
importData method
Imports data into the specified worksheet. This method requires different parameters depending
on the type of worksheet you are importing data into.
The worksheet specified must be designed for allowing data imports. For more information, see
the Maestro Resource Authoring Guide (Java client).
Syntax
worksheet.importData(importData, forceUpdate);
where worksheet is the worksheet object to import data into.
forceUpdate Boolean Optionally, whether the scenario is updated before the import operation begins.
Return value
The importData method returns an importResults object, which has the following properties.
Exceptions
The importData method can throw the following exceptions.
Exception Description
ArgumentError A null value, incorrect data type for a column, or an invalid date was specified.
Examples
Example of importing data into a crosstab worksheet. This example uses a crosstab worksheet
with four rows, two dimension columns, and five monthly buckets. The script changes the value
in the third bucket to 6000 for each row. All other values are unchanged.
Example of importing data into a vertical worksheet, and updating the scenario before importing
the data.
convertToJSON method
Converts a worksheet's data to a JSON string that can be sent to external systems and services.
You can specify the formatting applied to this string to make it fit the required input for the
system you are sending it to. Typically, you would use the return value from this method as one
of the inputs to an endpoint, as described in "invokeEndpoint method" on page 475.
Syntax
worksheetData.convertToJSON(startRow, pageSize, format)
format Object Defines the formatting applied to the JSON string, including the name for the
object that represents the data, how to format the rows, and a delimiter character
for separating values, if necessary.
The object that defines the formatting has the following properties:
Property Description
rowsObjectName The name for the entire data object in the JSON output. This is used to identify the data in
the endpoint call and should be set according to the expected input for the service or
system you send data to.
The data is output as an array of values formatted according to the settings specified in the
other properties of this object.
Default value: "Rows"
includeRowName Whether each row is represented as a separate object in the output. If false, the row values
are presented as an array of values.
Default value: true
rowName A name to identify each row of data in the output. This value is ignored if includeRowName
is false.
Default value: "Values"
delimiter Defines the delimiter character used to separate column values if rowOutputFormat is set
to AsDelimitedString. This must be a single character, or the equivalent to a single
character. For example, if you specify "\t" as the delimiter, a tab character is inserted
between the column values.
Any instances of the delimiter character in the column values are automatically escaped in
the output.
Default value: ","
Return value
Returns a JSON object that contains the worksheet values formatted according to the rules you
specified.
Exceptions
The convertToJSON method can throw the following
Exception Description
ArgumentError An argument is missing, or an invalid value was presented for the rowOutputFormat or
delimiter arguments.
Examples
The following example retrieves the first five records from a worksheet that contains part data
(name, site, primary part source, and description) and converts it into a JSON string with no row
identifier and column values represented as entries in an array.
The following example returns the same set of worksheet records as the previous example, with
each row represented as an object.
The following example returns the same set of worksheet records, with the rows represented as a
single string and values delimited by commas.
The following example returns the same set of worksheet records as the previous example, using
default values for the row names and pipe (|) delimited string instead.
The following example returns the same set of worksheet records as the previous examples,
using the default formatting values.
columns collection
The columns collection contains all columns defined in a worksheet, represented as
WorksheetColumn objects.
The columns collection implements only the collection iteration functions. For more information,
see "Resource collections" on page 107.
hideZeroValues Boolean Whether zero values are hidden if the column contains a quantity value.
imageMap collection
The imageMap collection contains all image mappings defined for a column, represented as
WorksheetColumnImageMapping objects.
The imageMap collection has the following property.
The imageMap collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
WorksheetColumnImageMapping object
The WorksheetColumnImageMapping object defines images that can display in a column. These
image mappings are contained in the imageMap collection.
The WorksheetColumnImageMapping object contains the following properties.
image String A base64-encoded String that represents an image file. This string can be displayed
as an image in an HTML document.
toolTip String The tooltip displayed when a user pauses the mouse pointer over the image.
The cells within each row are contained in the cells collection, which contains an index of
WorksheetDataCell objects. These objects contain the data values in each worksheet column for
a specific row.
pivotedColumnIndex Number For a crosstab row, the index of the crosstab row.
isPivotedandBucketed Boolean Whether the cell is used to define a crosstab worksheet's date buckets.
style Object A WorkbookStyle object that defines the font formatting and color for the
cell.
status String Describes how the data was retrieved. This can be one of the following values:
l OK: The data was retrieved successfully.
l MemoryLimitReached: Data could not be retrieved because the data set
consumed too much memory.
l Canceled: Data retrieval was canceled or interrupted.
number Number The row number of a row in the collection. The row
numbers start at one.
type String The type of data in the row. This can be one of the
following:
l Normal: The data from a vertical (tabular)
worksheet. Each cell in the row can have a
different data type, depending on the
columns in the worksheet.
l Subtotal: The data from a subtotal or grand
total row in a vertical worksheet. Each cell
contains the sum, average, maximum, or
minimum of all values in the column.
l TimeBasedSubtotal: The sum or average of
values over a period of time.
l Crosstab: The data from a crosstab
(horizontal) worksheet. Each cell in the row
represents data values for a single column
over a period of time.
value Number The data in the cell. The data type of the value property depends on the data in the
String worksheet cell.
Date If this data is intended to be imported into another worksheet, you might require
Boolean some additional processing on the data. The values used for this table are Javascript
types, which do not always map directly to Maestro types. For example, if you need a
DateTime value, you can use the Javascript Date type's toISOString() method to
correctly format the Javascript Date into a Maestro DateTime.
Dates in Javascript always include the time component, so you can use the
toDateString() or toTimeString() methods to return the date or time portion of the
value as a string, or use the getFullYear(), getMonth(), and getDate() methods to
construct a Maestro Date value.
The bucketing property refers to the Bucketing object, which has the following properties.
Method Description
slice(start [, Creates a new worksheet data row collection that contains a subset of another row collection,
end]) specified by the start and optional end parameters.
Method Description
get Retrieves the value in the column with the specified column identifier. You can use this method to
(columnId) retrieve data from a specific column regardless of its position in the worksheet.
Worksheet data values can be retrieved using the worksheet's getData() method and then
specified by row and cell index, or by row index and column identifier. For example, you can use
the following code to determine the value in the fourth cell of the fifth row of a worksheet's data.
get method
Retrieves a column from the worksheet data cells collection. The specified column identifier
maps to the column's index in the collection.
Syntax
column = worksheetRow.cells.get(columnId);
where worksheetRow is a WorksheetDataRow object.
Returns
A WorksheetDataCell object.
Exception Description
ArgumentError Either a blank or null value was specified for the columnId argument,
or more than one argument was provided.
Example
slice method
Creates a new worksheet data row collection based on an existing collection. The new collection
contains a subset of the rows in the original collection.
Syntax
rowCollection = worksheetDataRows.slice(start[, end]);
where worksheetDataRows is a row collection.
end Number Optionally, the last row index to include in the new array. Rows up to, but not
including, this row are added to the new data row collection.
This value can be set relative to the end of the collection by using a negative value.
For example, if end is -10, the new collection ends with the 10th row from the end
of the original collection.
If this value is not specified, the last row in the original collection is used.
Type Description
Object A worksheet data row collection
Exceptions
The slice method does not throw exceptions.
Example
close method
Closes a worksheet query after it has finished running. A closed query is removed from memory
and cannot be referenced, so this method should be the last one called when processing
worksheet data.
Syntax
worksheetData.close()
where worksheetData is a worksheet data row collection object.
Returns
No return value.
Exceptions
The close method does not throw exceptions.
Example
Method Description
execute() Performs the worksheet's data modification.
execute method
Runs the data modification defined in the specified worksheet.
Syntax
worksheet.dataModification.execute( [scenario] );
Returns
For reporting purposes, this method returns an object with the following properties.
Exceptions
The execute method can throw the following exceptions.
Exception Description
Worksheet.DataUpdateError An error occurred when modifying the data.
Examples
To run a worksheet's data modification:
var nDeleted = 0;
var worksheet = workbook_DataModification.worksheets.get("ScheduledReceipt");
nDeleted = worksheet.dataModification.execute().deleted;
BasicBucketSettings object
For a worksheet that uses basic bucketing, the BasicBucketSettings object defines the bucket
calendar and number of buckets displayed in the worksheet. This object contains the following
properties.
bucketStartDateModifiable Boolean Whether worksheet users can modify the start date.
intervals Object A BucketIntervals object that defines the buckets in the worksheet.
lockBucketing Boolean Whether worksheet users can modify the bucket settings.
options Object A BucketOptions object that defines the bucket options used in the
worksheet.
AdvancedBucketSettings object
For a worksheet that uses advanced bucket settings, the AdvancedBucketSettings object defines
the bucket settings used in the worksheet. This object contains the following properties.
includePastBucket Boolean Whether the Past bucket is included, which contains all values earlier
than the earliest bucket in the worksheet.
intervals Object A BucketIntervals object that defines the buckets in the worksheet.
lockBucketing Boolean Whether worksheet users can modify the bucket settings.
BucketInterval object
The BucketInterval object defines the intervals used in a bucketed worksheet. This object
contains the following properties.
numberOfBuckets Number How many buckets of this size are displayed in the worksheet.
direction String Whether the buckets are defined before or after the anchor date.
useSubtotalCalendar1 Boolean Whether the first subtotal calendar is displayed in the worksheet.
useSubtotalCalendar2 Boolean Whether the second subtotal calendar is displayed in the worksheet.
useSubtotalCalendar3 Boolean Whether the third subtotal calendar is displayed in the worksheet.
useSubtotalCalendar4 Boolean Whether the fourth subtotal calendar is displayed in the worksheet.
BucketOption object
The BucketOption object defines the properties of a bucket. This object contains the following
properties.
offset Object A BucketDateOffset object that defines the date offset for the anchor date.
BucketDateOffset object
The BucketDateOffset object defines the date and date offset used for defining a worksheet's
anchor date or start date relative to another date. This object contains the following properties.
BucketStartDate object
The BucketStartDate object defines the start date of basic bucketing displayed before the
worksheet's anchor date. The BucketStartDate contains the following properties.
offset Object The BucketDateOffset object that defines how the date is offset.
type String The type of anchor date the worksheet uses. This can be one of the following values:
l Planning: The planning date is used to define the anchor date.
l Today: The current date is used as the anchor date.
l Current: The beginning of a current calendar period is used as the anchor
date.
BucketCalendarToDate object
The BucketCalendarToDate object describes the calendar-to-date subtotals contained in the
worksheet bucketing. This object contains the following properties.
bucketLabel String The label of the bucket that contains the calendar-to-date subtotal.
origin String The date that the calendar-to-date subtotal is calculated to. This can be one
of the following values:
l Today
l Anchor Date
l Planning Date
originCalendar String The calendar that the origin value is in. The calendar-to-date subtotal is
calculated up to this period.
AutobucketInfo object
The AutobucketInfo object defines the automatically-generated bucket settings for a crosstab
worksheet. This object contains the following properties.
autobucketColumnId String The column identifier of the column that is used to define the
worksheet buckets.
allowPartialTimeSubtotals Boolean Whether the subtotals displayed in the worksheet can contain partial
buckets.
DateBucket object
The DateBucket object defines the beginning and end dates of a bucket.
WorksheetColumnDrillToDetail object
The WorksheetColumnDrillToDetail object defines links between worksheets or between
worksheets and forms. This object contains the following properties.
drillTarget String The worksheet or form object the drill to details link
opens. For
label String The label displayed for the drill to details link.
columnMappings collection
The columnMappings collection contains all drill to details links defined in a worksheet,
represented as DrillToDetailColumnMapping objects.
The columnMappings collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
DrillToDetailColumnMapping object
The DrillToDetailColumnMapping object defines the values mapped from one column to
another by a drill to details link in a worksheet. The drill to details links for a column are
contained in the drillToDetailColumnMappings collection.
The DrillToDetailColumnMapping object has the following properties.
WorksheetColumnDrillToDetailBucketVariable
Mappings object
The WorksheetColumnDrillToDetailBucketVariableMappings object defines the mapping
between a date bucket in a source worksheet and the date range in a detail worksheet. The
WorksheetColumnDrillToDetailBucketVariableMappings object has the following properties.
WorksheetColumnDrillToDetailColumnMappin
g object
The WorksheetColumnDrillToDetailColumnMapping object defines how a column in a source
worksheet maps to a column in a detail worksheet. The value in the source column is used as a
column search on the detail worksheet. The WorksheetColumnDrillToDetailColumnMapping
object has the following properties.
targetId String The column identifier of the column in the detail worksheet.
DrillTarget object
The DrillTarget object defines the target of a drill to details link. This object contains the
following properties.
The TreemapQuery object defines the underlying data that implements a treemap. This includes
the data displayed in the treemap and the dimensions and measures the treemap uses. The
TreemapQuery object contains the following properties.
measures Object A TreemapQueryColorMeasure object that defines the size and color
measures that define the treemap.
supportsHierarchies Boolean Whether the treemap can use hierarchy values in its dimensions.
TreemapQueryDimension object
The TreemapQueryDimension object defines the dimensions that determine the data displayed
in the treemap, including how the data is divided and the size of each data region. These objects
are contained in the dimensions collection.
The TreemapQueryDimension object has the following properties.
index Number The dimension's index within the collection. The array starts with zero.
dimensions collection
The dimensions collection contains the TreemapQueryDimension objects that define the
dimensions of a treemap.
The dimensions collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
values String An array of values aggregated to generate the summary value for the dimension value.
cells Object A collection of treemap data cell objects representing the data in each cell of the
row.
index Number A cell's position in the array. The index starts at zero.
value Number The raw value in the cell. The data type of the value property depends on the
String data in the cell.
Date
Boolean
The cells within each row are contained in the cells collection, which contains an index of
TreemapQueryCell objects. These objects contain the data values in each treemap column for a
specific row.
The rows and cells collections both implement only the collection iteration functions. For more
information, see "Resource collections" on page 107.
TreemapDrillToDetail object
The TreemapDrillToDetail object defines drill to details links from the treemap to another
worksheet or workbook. The TreemapDrillToDetail object has the following properties.
dependencyId String The dependency identifier for the workbook the drill to
details link opens.
isTargetWorksheetTransformation Boolean Indicates whether the target of the drill to details link is a
transformation worksheet.
isTargetWorksheetTreemap Boolean Indicates whether the target of the drill to details link is
another treemap.
worksheetId String The identifier of the worksheet the drill to details link opens.
columnMappings collection
The columnMappings collection contains all TreemapDrillToDetailMapping objects defined for a
treemap.
This collection implements only the collection iteration functions. For more information, see
"Resource collections" on page 107.
Treemap methods
The TreemapQuery object contains the following method.
Method Description
getData(options) Retrieves the data the treemap contains.
getData method
This method returns the data used to create a treemap.
Syntax
data = treemap.getData(options);
where treemap is a TreemapQuery object.
Returns
A TreemapQueryData object that contains the rows and cells of data that are used to create the
treemap.
Exceptions
The getData method can throw the following exception.
Exception Description
ArgumentError Either the dimensions are missing or an extra argument has been provided.
Filter objects define values or expressions that are used to limit the records displayed in a
worksheet. All filters available to the user running the script are contained in the filters collection.
Filter objects have the same properties as Resource objects, as well as the following property.
filters collection
The filters collection contains all Filter objects the user running the script has access to. The filters
collection implements the following resource collection methods.
The filters collection also implements the collection indexing and iteration functions. For more
information, see "Collection indexing" on page 108.
get method
Retrieves a Filter object.
Syntax
filter = rapidResponse.filters.get({name, scope});
You can also retrieve the filter using its id property, if you know it or can access it.
filter = rapidResponse.filters.get(id);
where id is a string that contains the filter's id property, which is a GUID consisting of upper and
lower case letters, numbers, and hyphens, in the format {8 characters}-{4 characters}-{4
characters}-{4 characters}-{12 characters}.
Returns
A Filter object.
Exceptions
The get method can throw the following exceptions.
Exception Description
Filter.NotFound The specified filter does not exist or the user does not have access to it.
exists method
Determines whether a filter exists. However, because Maestro supports multiple users working
with the same resources, a user might delete the specified filter after this method runs. If you are
using this method to test whether a filter exists, you should still catch a NotFound exception for
the filter you are using.
Syntax
filterExists = rapidResponse.filters.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the filter exists
l false if the filter does not
exist
Exceptions
The exists method can throw the following exception.
Example
Test for the existence of filters, and either retrieve a workbook using the first one a user has
access to or use a filter expression if the user has access to none of the specified filters.
var filterCondition;
if(rapidResponse.filters.exists({name:"All Parts", scope:"Public"})) {
filterCondition = {name:"All Parts", scope:"Public"};
} else if(rapidResponse.filters.exists({name:"Buy Parts", scope:"Public"})){
filterCondition = {name:"Buy Parts", scope:"Public"};
} else {
var allFilters = rapidResponse.filters.toArray();
filterCondition = allFilters[0];
}
remove method
Deletes a filter from the server, which also removes it from the filters collection. Deleted filters
are no longer available to any user or process, and you can only delete filters you own or have
permission to manage.
Return value
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Filter.NoPermission You do not have permission to delete the specified script.
Example
Method Description
give Gives the filter to the specified user.
(newOwner)
makePublic() Changes the scope of a filter to "Public", which is the equivalent of sharing the filter. Public filters
can be accessed by administrators and users and groups with access.
You can also share a filter with a particular user or group using the accessControlList collection's
add method.
Syntax
filter.give(newOwner);
where filter is a Filter object.
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Filter.NotFound The specified filter does not exist.
Filter.NonUniqueName The specified user already owns a filter with the same name as the one you are giving.
Example
makePublic method
Changes the scope of the specified filter from "Private" to "Public", which shares the filter and
allows other users to access it. This method does not specify other users or groups to share the
filter with, so it is available to only you and administrators.
Syntax
publicFilter = filter.makePublic();
where filter is a Filter object.
Return value
A Filter object that represents the same filter with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
Filter.NotFound The specified filter does not exist.
Filter.NonUniqueName A shared filter with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a filter.
Syntax
filter.rename(newName);
where filter is a Filter object.
Return value
A Filter object with the new name.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Filter.NameValidationError Either a filter with the same name already exists or the specified name is not valid.
Filter.NoPermission The filter cannot be renamed or you do not have permission to rename it.
Example
copy method
Creates a new filter by copying an existing filter. If you copy a public filter, the copy is private.
Syntax
filter.copy(newName);
where filter is a Filter object.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Filter.NameValidationError Either a filter with the same name already exists or the specified name is not valid.
Filter.NoPermission The filter cannot be copied or you do not have permission to copy it.
Example
CompositeFilterData object
The CompositeFilterData object defines the data settings that comprise a
CompositeFilterManager object. This object contains the following objects.
filterManagerIds Object The set of FilterManager objects that use this filter item.
isValid Boolean Whether this filter item is valid for the specified worksheet.
ScenarioGroup object
The ScenarioGroup object defines the scenarios used in a FilterManager object. This object
contains the following properties.
filterManagerIds Object A set of FilterManager objects that use this scenario group.
HierarchyGroup object
The HierarchyGroup object defines the hierarchies used in a FilterManager object. This object
contains the following properties.
filterManagerIds Object The set of FilterManager objects that use the hierarchy group.
BucketSettingsGroup object
The BucketSettingsGroup object defines the bucket settings used in a FilterManager object. This
object contains the following properties.
filterManagerIds Object The set of FilterManager objects that use this bucket settings group.
FilterManagerFactory object
The FilterManagerFactory object defines methods used for constructing filtering settings for
workbooks. The FilterManagerFactory object contains the following methods.
Method Description
createFilterManager(workbook, Creates a FilterManager object using the specified workbook, worksheet,
worksheet, {settings}) and optional display settings.
createFilterManager method
Creates a FilterManager object using a specific workbook, worksheet, and display settings.
Syntax
filter = rapidResponse.filtering.createFilterManager(workbook, worksheet,
{controlSettings, bucketSettings, preferences});
controlSettings Object A ControlSettings object that defines the data in the worksheet.
bucketSettings Object An optional BucketSettings object that defines the bucketing used in the
worksheet.
preferences Object An optional WorkbookPreferences object that defines the user settings for the
workbook.
Returns
A FilterManager object.
Exception Description
ArgumentError One of the following has occurred:
l A null value or no value was passed to the workbook or worksheet
argument.
l The value passed to an argument was the incorrect data type.
l Too many arguments were passed to the method.
Example
var controls = {
scenarios: [{ name:"myScenario", scope:"Private" }],
filter: {name: "Buy Parts", scope:"Public"},
siteGroup: {name: "DC-Asia", scope: "Public"},
part: "Racer"
};
var myWorkbook = rapidResponse.workbooks.get({ name:"My Workbook",
scope:"Public" }, controls);
var myWorksheet = myWorkbook.worksheets.get("AllOrders");
var myFilter = rapidResponse.filtering.createFilterManager(myWorkbook,
myWorksheet, {controlSettings: controls});
createCompositeFilterManager method
Creates a composite filter setting.
Syntax
compFilter = rapidResponse.filtering.createCompositeFilterManager
(filterManagerIDs);
Returns
A CompositeFilterManager object.
Exception Description
ArgumentError One of the following has occurred:
l A null or blank value was passed to the filterManagerIds argument.
l The value passed to the filterManagerIds argument was the incorrect data
type.
l Too many arguments were passed to the method.
Example
FilterManager object
The FilterManager object defines the filtering settings applied to a worksheet. The FilterManager
object has the following property.
Method Description
getWorkbookBaseTable() Retrieves the table that filters must be compatible with to be applied to the
worksheet.
getUsesSelectedFilter() Retrieves whether the worksheet uses the currently selected filter.
getFilterItems() Retrieves the filter items from a worksheet a filter manager is defined on.
The FilterManager object also uses a FilterManagerFilterItem object, which displays a list of filter
items specified by type. Both the selected filter item and all available filter items of that type
display in the list.
level Number Level of indentation specified for the filter item in the Settings pane.
For example, an item at level 3 is a child of an item at level 2.
displayValue String The display value (label) for the filter time. This value displays in the Settings
pane.
dataValue Object By default, the display value. Specifically for scenario, filter, and site filter items, it
is an instance of the resource object.
The filterManager object also uses a filterManagerFilterItemValue object which displays the list
of available filter items.
displayValue String The display value (label) for the filter time. This value displays in the Settings pane.
dataValue Object By default, the display value. Specifically for scenario, filter, and site filter items, it is
an instance of the resource object.
getWorkbookBaseTable method
Retrieves the table compatibility for a workbook a filter manager object is based on.
Returns
A String value.
Exceptions
The getWorkbookBaseTable method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
Examples
var controls = {
scenarios: [{ name:"myScenario", scope:"Private" }],
filter: {name: "Buy Parts", scope:"Public"},
siteGroup: {name: "DC-Asia", scope: "Public"}
};
var myWorkbook = rapidResponse.workbooks.get({ name:"My Workbook",
scope:"Public" }, controls);
var myWorksheet = myWorkbook.worksheets.get("AllOrders");
This example conditionally runs a script depending on the workbook's filter compatibility, using
the same FilterManager object defined in the previous example.
getUsesSelectedFilter method
Retrieves whether the user's selected filter can be used with the worksheet defined in a
FilterManager object.
Syntax
useFilter = filterManager.getUsesSelectedFilter();
where filterManager is a FilterManager object.
Returns
A Boolean value.
Exceptions
The getUsesSelectedFilter method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
Example
getMultiScenarioCount method
Retrieves the number of scenarios used in the workbook a filter manager object is based on.
Returns
A Number value.
Exceptions
The getMultiScenarioCount method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
Example
getWorkbookVariables method
Retrieves the workbook variables in the workbook the filter manager is defined on.
Syntax
variableSet = filterManager.getWorkbookVariables();
where filterManager is a FilterManager object.
Returns
An array of WorkbookVariable objects.
Exceptions
The getWorkbookVariables method can throw the following exception.
Example
getBucketSettings method
Retrieves the bucket settings from a worksheet a filter manager is defined on.
Syntax
buckets = filterManager.getBucketSettings();
where filterManager is a FilterManager object.
Returns
A BucketSettings object.
Exceptions
The getBucketSettings method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
Example
getFilterItems method
Retrieves the filter items from a worksheet a filter manager is defined on.
Syntax
filterManager.getFilterItems(type);
where filterManager is a FilterManager object.
Returns
A set of FilterManagerFilterItem objects.
Exceptions
The getFilterValues method can throw the following exceptions.
Exception Description
ArgumentError The value specified for the type parameter is not a valid control type.
Example
getFilterValues method
Retrieves the values from a filter item.
Syntax
values = filterManager.getFilterValues(type, variableName);
where filterManager is a FilterManager object.
variableName String The name of the variable to retrieve values from. This parameter is required only if
you specified "variable" for the type parameter.
This method should be used with variables that can contain multiple values, such as
list or filter variables.
Returns
A set of String values.
Exceptions
the getFilterValues method can throw the following exceptions.
Exception Description
ArgumentError The value specified for the type parameter is not a valid control type, or a variable name was
not provided for the "variable" type.
Examples
This example retrieves all scenarios available to be used in a worksheet.
This example retrieves all variable values available to a workbook list variable named
"orderProcess".
getHierarchyNode method
Retrieves the selected hierarchy value.
Syntax
selectedLevel = filterManager.getHierarchyNode(hierarchyKey, hierarchyPath);
where filterManager is a FilterManager object.
Returns
A String value.
Exceptions
The getHierarchyNode method can throw the following exception.
Example
isMultiScenario method
Retrieves whether the workbook the filter manager object is based on is multi-scenario.
Syntax
isMulti = filterManager.isMultiScenario();
where filterManager is a FilterManager object.
Returns
A Boolean value.
Exceptions
The isMultiScenario method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
validate method
Determines if a FilterManager object is valid for a worksheet.
Syntax
validFilter = FilterManager.validate();
where FilterManager is a FilterManager object.
Returns
A Boolean value.
Exceptions
The validate method can throw the following exceptions.
Exception Description
ArgumentError A parameter was provided.
Example
CompositeFilterManager object
The CompositeFilterManager object defines the filtering settings applied to a composite
worksheet. The CompositeFilterManager object contains the following method.
Method Description
getData() Retrieves the data defined by the composite filter settings.
getData method
Retrieves the data defined by a CompositeFilterManager object.
Syntax
filterData = compositeFilter.getData();
where compositeFilter is a CompositeFilterManager object.
Returns
A CompositeFilterData object.
Exceptions
The getData method can throw the following exception.
Exception Description
ArgumentError An argument was passed to the method.
Example
var compFilter =
rapidResponse.FilterManagerFactory.createCompositeFilterManager([filter.id,
secondFilter.id]);
hierarchies collection
The hierarchies collection contains all Hierarchy objects the user running the script has access to.
The hierarchies collection implements the following resource collection methods.
Method Description
get({name, scope}) Retrieves the specified hierarchy.
The hierarchies collection also implements the collection indexing and iteration functions. For
more information, see "Collection indexing" on page 108.
get method
Retrieves a Hierarchy object.
Syntax
hierarchy = rapidResponse.hierarchies.get({name, scope});
You can also retrieve the hierarchy using its id property, if you know it or can access it.
hierarchy = rapidResponse.hierarchies.get(id);
where id is a string that contains the hierarchy's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A Hierarchy object.
Exceptions
The get method can throw the following exceptions.
Exception Description
Hierarchy.NotFound The specified hierarchy does not exist or the user does not have access to it.
Example
exists method
Determines whether a hierarchy exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified hierarchy after this method
Syntax
exists = rapidResponse.hierarchies.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the hierarchy exists
l false if the hierarchy does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
Method Description
give Gives the hierarchy to the specified user.
(newOwner)
makePublic() Changes the scope of a hierarchy to "Public", which is the equivalent of sharing the hierarchy.
Public hierarchies can be accessed by administrators and users and groups with access.
You can also share a hierarchy with a particular user or group using the accessControlList
collection's add method.
give method
Gives a hierarchy to the specified user.
Syntax
hierarchy.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Hierarchy.NonUniqueName The specified user already owns a hierarchy with the same name as the one you
are giving.
Example
makePublic method
Changes the scope of the specified hierarchy from "Private" to "Public", which shares the
hierarchy and allows other users to access it. This method does not specify other users or groups
to share the hierarchy with, so it is available to only you and administrators.
If you call this method on a variable that represents a hierarchy, you must ensure you assign the
returned public hierarchy to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the hierarchy with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared hierarchy, and you can allow other users and groups to
access a shared hierarchy.
Syntax
publicHierarchy = hierarchy.makePublic();
Return value
A Hierarchy object that represents the same hierarchy with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Hierarchy.NonUniqueName A shared hierarchy with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a hierarchy.
Syntax
hierarchy.rename(newName);
where hierarchy is a Hierarchy object.
Return value
A Hierarchy object with the new name.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Hierarchy.NameValidationError Either a hierarchy with the same name already exists or the specified name is
not valid.
Example
copy method
Creates a new hierarchy by copying an existing hierarchy. If you copy a public hierarchy, the copy
is private.
Syntax
hierarchy.copy(newName);
where hierarchy is a Hierarchy object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Hierarchy.NoPermission The hierarchy cannot be copied or you do not have permission to copy it.
Example
The SiteGroup object defines a site or site filter, and is used to identify the site or sites that a
resource uses. SiteGroup objects are contained in the siteGroups collection.
SiteGroup objects have the same properties as Resource objects. In addition, the siteGroup object
also has the following property:
For the SiteGroup object's scope property, individual sites always have a "Public" scope. The
methods defined by the SiteGroup object or collection typically apply only to site filters.
siteGroups collection
The siteGroups collection contains all sites and site filters available to the user running the script.
The siteGroups collection implements the following resource collection methods.
Method Description
get (key) Retrieves a site or site filter.
exists (siteGroup) Determines whether the specified site or site filter exists in the collection.
get method
Retrieves an instance of a site or site filter.
Syntax
rapidResponse.siteGroups.get( {name, scope} );
You can also retrieve the site using its id property, if you know it or can access it.
site = rapidResponse.siteGroups.get(id);
where id is a string that contains the site's id property, which is a GUID consisting of upper and
lower case letters, numbers, and hyphens, in the format {8 characters}-{4 characters}-{4
characters}-{4 characters}-{12 characters}.
Return value
A SiteGroup object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A null value was passed to a parameter.
SiteGroup.NotFound The specified site or site filter does not exist or you do not have access to it.
exists method
Determines whether a specific site or site filter exists in the collection. However, because Maestro
supports multiple users working with the same resources, a user might delete the specified site
or site filter after this method runs. If you are using this method to test whether a site or site filter
exists, you should still catch a NotFound exception.
Syntax
rapidResponse.siteGroups.exists({name: "Name", scope:"Public or Private"});
Return value
Type Description
Boolean l true if the site or site filter exists
l false if the site or site filter does not
exist
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
remove method
Deletes a site filter from the server, which also removes it from the siteGroups collection.
Deleted site filters are no longer available to any user or process, and you can only delete site
filters you own. This method applies only to site filters, and cannot delete sites.
Syntax
rapidResponse.siteGroups.remove(siteGroup);
Return value
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
SiteGroup.NoPermission You do not have permission to delete the specified site filter.
Method Description
give Gives the site filter to another user.
(newOwner)
makePublic() Changes the scope of a site filter to "Public", which is the equivalent of sharing the site filter.
Public site filters can be accessed by any user or group with access to at least one site in the filter.
give method
Gives a site filter to another user.
Syntax
siteGroup.give(newOwner);
where siteGroup is a SiteGroup object.
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Example
makePublic method
Makes a private site filter public. A public site filter is available to any user who has access to at
least one site contained in the site filter.
If you call this method on a variable that represents a site filter, you must ensure you assign the
returned public site filter to the same variable. Otherwise, the variable retains the scope it was
created with.
Syntax
publicSiteGroup = siteGroup.makePublic();
where siteGroup is a SiteGroup object.
Return value
A SiteGroup object that represents the same site filter with its scope changed to "Public"
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
SiteGroup.NotFound The specified site filter does not exist.
rename method
Changes the name of a site filter.
Syntax
siteGroup.rename(newName);
where siteGroup is a SiteGroup object.
Return value
No return value.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
SiteGroup.NameValidationError Either a site filter with the same name already exists or the specified name is
not valid.
copy method
Creates a new site filter by copying an existing site filter.
Syntax
siteGroup.copy(newName);
where siteGroup is a SiteGroup object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
SiteGroup.NameValidationError Either a site filter with the same name already exists or the specified name is
not valid.
SiteGroup.NoPermission The site filter cannot be copied or you do not have permission to copy it.
Examples
This example copies a site filter.
This example copies a site filter, and then gives the copy to a user who will modify it.
Alert objects define alerts, which can be used to monitor data and create reports. Alert objects are
contained in the alerts collection. For more information, see "alerts collection" on page 298.
Alerts have the same properties as Resource objects.
alerts collection
The alerts collection contains all alerts available to the user running the script. Any alert
retrieved or run by the script must be present in this collection.
The alerts collection implements the following resource collection methods.
Method Description
get(key) Retrieves the alert object with the specified resource key.
get method
Retrieves an instance of an alert object.
You can also retrieve the alert using its id property, if you know it or can access it.
alert = rapidResponse.alerts.get(id);
where id is a string that contains the alert's id property, which is a GUID consisting of upper and
lower case letters, numbers, and hyphens, in the format {8 characters}-{4 characters}-{4
characters}-{4 characters}-{12 characters}.
Returns
An alert object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank String or null value was passed to the method.
Example
Syntax
alertExists = rapidResponse.alerts.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the alert exists
l false if the alert does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
This example checks for the existence of an alert, and then if it exists, retrieves and runs it.
remove method
Deletes an alert from the server, which also removes it from the alerts collection. Deleted alerts
are no longer available to any user or process, and you can only delete alerts you own or have
permission to manage.
Syntax
rapidResponse.alerts.remove(alert);
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Alert.NoPermission You do not have permission to delete the specified alert.
Method Description
give Changes the owner of an alert.
(newOwner)
makePublic() Changes the scope of an alert to "Public", which is the equivalent of sharing the resource. Public
resources can be accessed by administrators and users and groups with access.
Method Description
runAsync() Runs the alert. The alert runs asynchronously.
give method
Gives an alert to another user. The recipient must have permission to author alerts.
Syntax
alert.give(owner);
where alert is an alert object.
Exceptions
The give method can throw the following exceptions.
Exception Description
Alert.NotFound The specified alert does not exist.
Example
makePublic method
Changes the scope of the specified alert from "Private" to "Public", which shares the alert and
allows other users to access it. This method does not specify other users or groups to share the
alert with, so it is available to only you and administrators.
If you call this method on a variable that represents an alert, you must ensure you assign the
returned public alert to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the alert with specific users and groups using the
Administrators can access any shared alert, and you can allow other users and groups to access a
shared alert.
Syntax
publicAlert = alert.makePublic();
Returns
An Alert object that represents the same alert with its scope changed to "Public".
Exception Description
Alert.NotFound The specified alert does not exist.
Example
rename method
Changes the name of an alert. You can rename only private alerts that you own.
Syntax
alert.rename(newName);
Returns
No return value.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Example
copy method
Creates a new private alert by copying an existing alert. If you copy a shared alert, the copy is
private.
Syntax
alert.copy(newName);
Returns
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Alert.NameValidationError Either an alert with the same name already exists or the specified name is not valid.
Alert.NoPermission The alert cannot be copied or you do not have permission to copy it.
runAsync method
Runs an alert. When a script runs an alert, the alert runs asynchronously, and the script cannot
wait for the alert to finish.
Syntax
alert.runAsync();
where alert is an alert object.
Returns
No return value.
Exceptions
The runAsync method can throw the following exceptions.
Exception Description
Alert.AlreadyRunning The alert is already running with the same data settings.
Alert.ScenarioDoesNotExist The scenario specified in the alert's settings does not exist.
Example
ScheduledTask objects define scheduled tasks, which can be used to run workbook data
modifications or scripts, or to publish data to a subscriber. Scheduled task objects are contained
in the scheduledTasks collection. For more information, see "scheduledTasks collection" on
page 308.
Scheduled tasks have the same properties as Resource objects.
scheduledTasks collection
The scheduledTasks collection contains all scheduled tasks available to the user running the
script. Any scheduled task retrieved or run by the script must be present in this collection.
The scheduledTasks collection implements the following resource collection methods.
Method Description
get(key) Retrieves the scheduled task object with the specified resource key.
Syntax
rapidResponse.scheduledTasks.get({name, scope});
You can also retrieve the scheduled task using its id property, if you know it or can access it.
task = rapidResponse.scheduledTasks.get(id);
where id is a string that contains the scheduled task's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A scheduled task object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank String or null value was passed to the method.
Example
exists method
Determines whether a scheduled task exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified scheduled task after this
method runs. If you are using this method to test whether a scheduled task exists, you should
still catch a NotFound exception for the scheduled task you are using.
Syntax
taskExists = rapidResponse.scheduledTasks.exists({name: "Name", scope:
"Public or Private"});
Returns
Type Description
Boolean l true if the scheduled task exists
l false if the scheduled task does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
This example checks for the existence of a scheduled task, and then if it exists, retrieves and runs
it.
remove method
Deletes a scheduled task from the server, which also removes it from the scheduledTasks
collection. Deleted scheduled tasks are no longer available to any user or process, and you can
only delete scheduled tasks you own or have permission to manage.
Syntax
rapidResponse.scheduledTasks.remove(task);
Returns
No return value.
Exception Description
ScheduledTask.NoPermission You do not have permission to delete the specified scheduled task.
Example
Method Description
give Changes the owner of a scheduled task.
(newOwner)
makePublic() Changes the scope of a scheduled task to "Public", which is the equivalent of sharing the task.
Public resources can be accessed by administrators and users and groups with access.
Method Description
runAsync() Runs the scheduled task. The task runs asynchronously.
give method
Gives a scheduled task to another user. The recipient must have permission to author scheduled
tasks.
Returns
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
ScheduledTask.NotFound The specified scheduled task does not exist.
Example
makePublic method
Changes the scope of the specified scheduled task from "Private" to "Public", which shares the
scheduled task and allows other users to access it. This method does not specify other users or
groups to share the scheduled task with, so it is available to only you and administrators.
If you call this method on a variable that represents a scheduled task, you must ensure you
assign the returned public scheduled task to the same variable. Otherwise, the variable retains
the scope it was created with.
You can also share the scheduled task with specific users and groups using the accessControlList
collection's add method.
Syntax
publicScheduledTask = scheduledTask.makePublic();
Returns
A ScheduledTask object that represents the same scheduled task with its scope changed to
"Public".
Exceptions
The makePublic method can throw the following exceptions
Exception Description
ScheduledTask.NotFound The specified scheduled task does not exist.
Example
rename method
Changes the name of a scheduled task. You can rename only private scheduled tasks that you
own.
Syntax
scheduledTask.rename(newName);
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the
newName parameter.
ScheduledTask.NameValidationError Either a scheduled task with the same name already exists or the
specified name is not valid.
Example
copy method
Creates a new private scheduled task by copying an existing scheduled task. If you copy a shared
scheduled task, the copy is private.
Syntax
scheduledTask.copy(newName);
Returns
No return value.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the
newName parameter.
ScheduledTask.NameValidationError Either a scheduled task with the same name already exists or the
specified name is not valid.
ScheduledTask.NoPermission The scheduled task cannot be copied or you do not have permission to
copy it.
Example
runAsync method
Runs a scheduled task. When a script runs a scheduled task, the task runs asynchronously, and
the script cannot wait for the task to finish or use any data returned by the task.
Syntax
scheduledTask.runAsync(overrides);
where scheduledTask is a scheduled task object and overrides is an optional object defining
settings to be overridden when the script runs this scheduled task. To use an override, the
scheduled task must allow users to modify the data or notification settings.
Returns
No return value.
However, if the scheduled task runs a script, an identifier named TaskActivityId is generated,
which you can use to relate the scheduled task run with the script. You can also use this identifier
to create scripts that only run in the context of a scheduled task. For more information, see
"Define arguments for a script" on page 62. A unique TaskActivityId value is generated every
time the scheduled task runs.
Exception Description
ScheduledTask.AlreadyRunning The scheduled task is already running and cannot be started again until
it finishes.
ScheduledTask.ScenarioDoesNotExist The scenario specified in the scheduled task's data settings does not
exist.
Note: This exception can only occur if the specified scheduled task
modifies data.
Example
This example runs a scheduled task with no overrides.
This example runs the same task with a different scenario and includes the Supply Planners
group on the success notification message.
This example runs a schedule task that triggers a script that creates a new scenario. This script
creates the new scenario name as a combination of a string and a date passed to the script, and
includes a purpose and a toggle to share it after it is created. The default arguments for the script
use the Baseline scenario as the parent, the Today date constant as the date, a generic purpose,
and share the scenario.
You can set all the scenario arguments by overriding them using the Parameters object.
extendedFilterConstraint String A specific constraint to use in the scheduled task. This property
maps to the Constraint control in a worksheet based on the
Constraint table, and can be used only with workbooks compatible
with the Constraint table.
Valid values for this property include a constraint name in single
quotes, or the * character for all constraints. For example,
"'PaintBooth'" or "*".
extendedFilterProcessInstance String A specific process instance to use in the scheduled task. This
property maps to the Process Instance control in a worksheet
based on the Process Instance table, and can be used only with
workbooks compatible with the ProcessInstance table.
Valid values for this property include a process instance name in
single quotes, or the * character for all process instances. For
example, "'Process 1'" or "*".
extendedFilterProject String A specific project to use in the scheduled task. This property maps
to the Project control in a worksheet based on the Project table,
and can be used only with workbooks compatible with the Project
table.
Valid values for this property include a project name in single
quotes, or the * character for all projects. For example, "'Nova'"
or "*"
extendedFilterWorkCenter String A specific work center to use in the scheduled task. This property
maps to the Work Center control in a worksheet based on the
WorkCenter table, and can be used only with workbooks
compatible with the WorkCenter table.
Valid values for this property include a work center name in single
quotes, or the * character for all work centers. For example,
"'Punch Press'" or "*"
model String The model name to use. Valid values for this property include a
model name in single quotes, or the * character for all models. For
example, "'LtBlue'" or "*"
unitOfMeasure String The units used for quantities that allow unit conversions.
Parameters Object An array of values for the variables you want to override. This
object uses the variable name as the property name to override.
Each variable is defined in this object as a name:value pair, for
example, customer:"MyShop". Any entry in this array that does
not correspond to a workbook variable is ignored.
NotificationSettings Object Defines the users to notify and the notification messages to send
on success and on failure. See "Overriding the notification settings"
on page 322.
The hierarchies property refers to a hierarchy object, which has the following properties.
path Object The values selected in the hierarchy. This property includes the names of the hierarchy
values and optionally, values selected in levels underneath the current level.
childPath Object The values selected in the level below the current level. The childPath property is a
path object, so each childPath can have its own childPath, until the last level of the
hierarchy is reached. The last level of the hierarchy has a blank value for its childPath.
NotificationSettings Object Defines the users to notify and the notification messages to send on success
and on failure. See "Overriding the notification settings" on page 322.
OnFailure Object Contains properties for overriding the message recipients, message header and body,
and who gets notified when the scheduled task fails.
CC String Defines a user or list of users, separated by semicolons, who are added to the
recipient list as carbon copy recipients for the message.
SendToOwner Boolean Whether the message is sent to the scheduled task's owner.
SendToUser Boolean Whether the message is sent to user who ran the scheduled task.
Subject String For the OnSuccess object only, the subject line for the message.
Body String For the OnSuccess object only, the message body to send.
SendToSuccessList Boolean For the OnFailure object only, whether the message is sent to the same list of
users defined in the OnSuccess object.
The AutomationChain object defines an automation chain, which is used to run a sequence of
other automation tasks. All automation chains you have access to are contained in the
automationChains collection. For more information, see "automationChains collection" on page
324.
AutomationChain objects have the same properties as Resource objects.
automationChains collection
The automationChains collection contains all automation chains available to the user running
the script. Any automation chain retrieved or run by the script must be present in this collection.
The automationChains collection implements the following resource collection methods.
Method Description
get(key) Retrieves the automation chain object with the specified resource key.
Syntax
rapidResponse.automationChains.remove(automationChain);
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
AutomationChain.NoPermission You do not have permission to delete the specified automation chain.
Example
get method
Retrieves an instance of an automation chain object.
Syntax
rapidResponse.automationChains.get({name, scope});
You can also retrieve the automation chain using its id property, if you know it or can access it.
automation = rapidResponse.automationChains.get(id);
where id is a string that contains the automation chain's id property, which is a GUID consisting
of upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
An automation chain object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank String or null value was passed to the method.
Example
Syntax
autoChainExists = rapidResponse.automationChains.exists({name: "Name",
scope: "Public or Private"});
Returns
Type Description
Boolean l true if the automation chain exists
l false if the automation chain does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
This example checks if an automation chain exists and if so, runs it.
Method Description
give Changes the owner of an automation chain.
(newOwner)
makePublic() Changes the scope of an automation chain to "Public", which is the equivalent of sharing the task.
Public resources can be accessed by administrators and users and groups with access.
Method Description
runAsync() Runs the automation chain. The task runs asynchronously.
give method
Gives an automation chain to another user. The recipient must have permission to author
automation chains.
Syntax
automationChain.give(owner);
Returns
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
AutomationChain.NotFound The specified automation chain does not exist.
Example
makePublic method
Changes the scope of the specified automation chain from "Private" to "Public", which shares the
automation chain and allows other users to access it. This method does not specify other users
or groups to share the automation chain with, so it is available to only you and administrators.
If you call this method on a variable that represents an automation chain, you must ensure you
assign the returned public automation chain to the same variable. Otherwise, the variable retains
the scope it was created with.
You can also share the automation chain with specific users and groups using the
accessControlList collection's add method.
Administrators can access any shared automation chain, and you can allow other users and
groups to access a shared automation chain.
Returns
An AutomationChain object that represents the same automation chain with its scope changed
to "Public".
Exceptions
The makePublic method can throw the following exceptions
Exception Description
AutomationChain.NotFound The specified automation chain does not exist.
Example
rename method
Changes the name of an automation chain. You can rename only private automation chains that
you own.
Syntax
automationChain.rename(newName);
Returns
No return value.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the
newName parameter.
AutomationChain.NameValidationError Either an automation chain with the same name already exists or the
specified name is not valid.
Example
copy method
Creates a new private automation chain by copying an existing automation chain. If you copy a
shared automation chain, the copy is private.
Syntax
automationChain.copy(newName);
Returns
No return value.
Exceptions
The copy method can throw the following exceptions.
AutomationChain.NameValidationError Either an automation chain with the same name already exists or the
specified name is not valid.
Example
runAsync method
Runs an automation chain. When a script runs an automation chain, the automation chain runs
asynchronously, and the script cannot wait for the automation chain to finish or use any data
returned by steps in the automation chain.
Syntax
automationChain.runAsync(override);
where automationChain is an automation chain object and override is an optional object that
overrides the settings in the automation chain.
For automation chains, the override object contains a single property, StartAtStep, which defines
the step of the automation chain to begin on.
Returns
No return value.
Exceptions
The runAsync method can throw the following exceptions.
CompositeTask.LockedOut The automation chain is locked or at least one of the resources it depends on
is locked.
CompositeTask.InvalidProperty The override object includes a setting that cannot be modified in the
automation chain, such as notification settings. Automation chains do not
allow users to modify notification or data settings.
Example
This example does not use an override and begins at the first step.
Schedule objects define schedules that can be used to specify when an automation task runs. All
tasks that use the same schedule will run at the same time. A schedule can specify a specific time
to run the automation task, or to run the task on a data change or data update.
You cannot use a script to create or manage schedules, and the Schedule object does not
implement any of the Resource object properties or methods.
schedules collection
The schedules collection contains all schedules you have access to. This includes private
schedules you have created and all shared schedules.
The schedules collection implements the following methods.
Method Description
get(name) Retrieves a schedule from the collection
get method
Retrieves a schedule from the schedules collection.
Returns
A Schedule object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
exists method
Determines whether a schedule exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified schedule after this method
runs. If you are using this method to test whether a schedule exists, you should still catch a
NotFound exception for the schedule you are using.
Syntax
scheduleExists = rapidResponse.schedules.exists( {name, scope} );
Returns
Type Description
Boolean l true if the schedule exists
l false if the schedule does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
Method Description
runAutomationTasks() Runs all automation tasks that uses the schedule
runAutomationTasks method
Runs all automation tasks associated with a schedule. This runs every task regardless of the
schedule, and is equivalent to retrieving each task and calling its runAsync() method. Only
Syntax
Schedule.runAutomationTasks();
where Schedule is a Schedule object.
Returns
No return value.
Exceptions
The runAutomationTasks method throws the following exceptions
Exception Description
Schedule.NoPermission The user running the script is not a system administrator and does not have
permission to run this method.
Example
taskFlows collection
The taskFlows collection contains all TaskFlow objects the user running the script has access to.
The taskFlows collection implements the following resource collection methods.
Method Description
get({name, scope}) Retrieves the specified task flow.
exists(taskFlow) Determines whether the specified task flow exists in the collection.
The task flows collection also implements the collection indexing and iteration functions. For
more information, see "Collection indexing" on page 108.
get method
Retrieves a TaskFlow object.
Syntax
taskflow= rapidResponse.taskFlows.get({name, scope});
You can also retrieve the task flow using its id property, if you know it or can access it.
taskFlow= rapidResponse.taskFlows.get(id);
where id is a string that contains the task flow's id property, which is a GUID consisting of upper
and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A TaskFlow object.
Exceptions
The get method can throw the following exceptions.
Exception Description
TaskFlow.NotFound The specified task flow does not exist or the user does not have access to it.
Example
Syntax
exists = rapidResponse.taskFlows.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the task flow exists
l false if the task flow does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
Method Description
give Gives the task flow to the specified user.
(newOwner)
makePublic() Changes the scope of a task flow to "Public", which is the equivalent of sharing the task flow.
Public task flows can be accessed by administrators and users and groups with access.
You can also share a task flow with a particular user or group using the accessControlList
collection's add method.
give method
Gives a task flow to the specified user.
Syntax
taskFlow.give(newOwner);
Return value
No return value.
Exception Description
TaskFlow.NotFound The specified task flow does not exist.
TaskFlow.NonUniqueName The specified user already owns a task flow with the same name as the one you are
giving.
Example
makePublic method
Changes the scope of the specified task flow from "Private" to "Public", which shares the task
flow and allows other users to access it. This method does not specify other users or groups to
share the task flow with, so it is available to only you and administrators.
If you call this method on a variable that represents a task flow, you must ensure you assign the
returned public task flow to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the task flow with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared task flow, and you can allow other users and groups to
access a shared task flow.
Syntax
publicTaskFlow = taskFlow.makePublic();
Return value
A TaskFlow object that represents the same task flow with its scope changed to "Public".
Exception Description
TaskFlow.NotFound The specified task flow does not exist.
TaskFlow.NonUniqueName A shared task flow with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a task flow.
Syntax
taskFlow.rename(newName);
where taskFlow is a TaskFlow object.
Return value
A TaskFlow object with the new name.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
TaskFlow.NoPermission The task flow cannot be renamed or you do not have permission to rename it.
Example
copy method
Creates a new task flow by copying an existing task flow. If you copy a public task flow, the copy
is private.
Syntax
taskFlow.copy(newName);
where taskFlow is a TaskFlow object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
TaskFlow.NoPermission The task flow cannot be copied or you do not have permission to copy it.
Example
Property Description
name The exception name. This value is "RapidResponseError".
message Information about the error. This information can be reported in the console output in the script
log to help you debug the script. See "Script logging" on page 94.
stack A stack trace of the error. This property is available only if the script uses the RapidResponse 11.2
runtime.
The following errorCode values are possible for any method call.
errorCode Description
ArgumentError Either too many arguments are provided for a method, the values supplied are the wrong
type, or a null, undefined, or blank String value has been provided.
For each method called on resources, exceptions can be thrown with errorCode values that are
based on the object or collection a function is called on. For each of the following exceptions, the
ResourceType is the type of resource used in the call.
ResourceType.NonUniqueName A resource of the same type with the same name already exists.
ResourceType.NoPermission You do not have permission to perform the function on the resource.
Each resource type can throw exceptions that are unique to that resource.
ClientActions object
ClientAction objects are used to provide a list of actions to users from a script.
Method Description
addBookmark() Adds the created bookmark to an actions list.
addBookmark method
This method adds a bookmark created for a resource to the actions list that displays to users.
Syntax
rapidResponse.actions.addBookmark(resource);
Returns
No return value.
Exceptions
The addBookmark method can throw the following exception.
Exception Description
ArgumentError An invalid or null value was specified for the parameter or no argument or more than one
argument was specified for the method.
Examples
function main() {
const actions = rapidResponse.clientActions;
const dashboard = rapidResponse.dashboards.get({name: 'Adoption
Dashboard', scope: 'Public'});
const dashboardBookmarkDef = dashboard.createBookmarkDefinition();
actions.addBookmark(dashboardBookmarkDef);
return JSON.stringify(actions);
}
A ProfileVariable object defines a variable, which can contain a persisted value that can be used in
successive script executions. For example, you can store the script's last run date in a profile
variable, and use that value in the script to determine which operations of a command to run.
Profile variable objects are contained in the profileVariables collection. For more information,
see "profileVariables collection" on page 350.
Profile variable objects have the following properties.
profileVariables collection
The profileVariables collection contains all profile variables available to the user running the
script. Any profile variable retrieved or used in the script must be in this collection.
The profileVariables collection has the following methods.
set(name, value) Saves the specified value in the specified profile variable. If the variable does not
exist, it is created.
setConstantVariable(name, Saves the specified value in a Constant profile variable for a specific user or group.
value, principal) If the variable does not exist, it is created.
set method
Sets the value of a profile variable object, or creates the variable if it does not exist.
Syntax
rapidResponse.profileVariables.set(name, value);
Returns
The ProfileVariable object that was created or set.
Exceptions
The set method can throw the following exception.
Exception Description
ArgumentError A blank string or null value was passed to the method.
Example
Syntax
rapidResponse.profileVariables.setConstantVariable(name, value, principal);
principal String The user or group the profile variable belongs to.
The user running the script must have permission to modify macros and profile
variables to set or create profile variables for other users and groups.
Returns
The ProfileVariable object that was created or set.
Exceptions
The setConstantVariable method can throw the following exception.
Exception Description
ArgumentError A blank string or null value was passed to the method.
Example
Syntax
rapidResponse.profileVariables.get(name, principal);
principal String Optionally, the user or group the profile variable is defined for. If not provided, a
variable belonging to the user running the script is retrieved.
The user running the script must have permission to modify macros and profile
variables to retrieve profile variables for other users and groups.
Returns
The ProfileVariable object with the specified name.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
AccessControl.NoPermission You do not have permission to modify macros and profile variables for other
users and groups.
Example
The following example retrieves a profile variable for the user running the script.
The following example retrieves a profile variable for the Buyers group.
A ProcessingRule object defines a processing rule or system setting in Maestro. For example, the
value of the Client_AllowUserProfilePictures processing rule determines whether users' profile
pictures are displayed in Maestro. ProcessingRule objects are contained in the "processingRules
collection" on page 356.
ProcessingRule objects have the following properties.
processingRules collection
The processingRules collection contains all processing rules available to the user running the
script. Any processing rule used in the script must be in this collection.
The processingRules collection has the following method.
Method Description
get(id) Retrieves the value of the processing rule with the specified ID.
Syntax
rapidResponse.processingRules.get(id);
Returns
The value of the specified processing rule.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
Example
This example determines whether profile pictures are turned on in the Java client
rapidResponse.processingRules.get("Client_AllowUserProfilePictures").value;
The Dashboard object defines dashboards, which display information from widgets. All
dashboards available to the user running the script are contained in the dashboards collection.
In addition to the resource object properties, dashboard objects have the following property.
showDataSettingsDialogOnOpen Boolean Whether the Data Settings dialog box is displayed when the
dashboard is opened.
widgetStyleSettings Object A WidgetStyleSettings object that defines the layout for each
widget.
paddingLeft Number The number of pixels inserted to the left of each widget.
paddingRight Number The number of pixels inserted to the right of each widget.
widgetReferences collection
The widgetReferences collection contains all widgets included in a dashboard, represented as
WidgetReference objects.
The widgetReferences collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
WidgetReference objects
A WidgetReference object represents a widget used in a dashboard. The WidgetReference
object has the following properties.
controlSettings Object A ControlSettings object that defines the data display settings for the
widget.
bucketSettings Object A BucketSettings object that defines the buckets in the widget's
worksheet.
workbookPreferences Object A WorkbookPreferences object that defines the user settings for the
widget's workbook.
For more information about widgets, see "Widget objects" on page 370.
Method Description
get (key) Retrieves a dashboard object
exists (dashboard) Determines whether the specified dashboard exists in the collection
get method
Retrieves an instance of a dashboard object, which allows the dashboard to be used in other
methods and processes.
Syntax
Dashboard = rapidResponse.dashboards.get({name, scope});
Parameter Description
name The name of the dashboard to retrieve.
You can also retrieve the dashboard using its id property, if you know it or can access it.
dashboard = rapidResponse.dashboards.get(id);
where id is a string that contains the dashboard's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A dashboard object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank or null value was passed for a parameter.
Dashboard.NotFound The specified dashboard does not exist or you do not have access to it.
exists method
Determines whether a specific dashboard exists. However, because Maestro platform supports
multiple users working with the same resources, a user might delete the specified dashboard
after this method runs. If you are using this method to test whether a dashboard exists, you
should still catch a NotFound exception.
Syntax
dashboardExists = rapidResponse.dashboards.exists({name: "Name", scope:
"Public or Private"});
Returns
Type Description
Boolean l true if the dashboard exists
l false if the dashboard does not
exist
Exceptions
The exists method can throw the following exceptions.
Example
Method Description
give(newOwner) Gives the dashboard to the specified user.
makePublic() Changes the scope of a dashboard to "Public", which is the equivalent of sharing the
dashboard. Public dashboards can be accessed by administrators and users and
groups with access.
You can also share a dashboard with a particular user or group using the
accessControlList collection's add method.
give method
Gives a dashboard to the specified user.
Syntax
dashboard.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Dashboard.NotFound The specified dashboard does not exist.
Dashboard.NonUniqueName The specified user already owns a dashboard with the same name as the one
you are giving.
Example
makePublic method
Changes the scope of the specified dashboard from "Private" to "Public", which shares the
dashboard and allows other users to access it. This method does not specify other users or
groups to share the dashboard with, so it is available to only you and administrators.
If you call this method on a variable that represents a dashboard, you must ensure you assign
the returned public dashboard to the same variable. Otherwise, the variable retains the scope it
was created with.
You can also share the dashboard with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared dashboard, and you can allow other users and groups to
access a shared dashboard.
Return value
A Dashboard object that represents the same dashboard with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
Dashboard.NotFound The specified dashboard does not exist.
Dashboard.NonUniqueName A shared dashboard with the same name as the one you are sharing already
exists.
Example
rename method
Changes the name of a dashboard.
Syntax
dashboard.rename(newName);
where dashboard is a Dashboard object.
Return value
A Dashboard object with the new name.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Dashboard.NameValidationError Either a dashboard with the same name already exists or the specified name
is not valid.
Dashboard.NoPermission The dashboard cannot be renamed or you do not have permission to rename
it.
Example
copy method
Creates a new dashboard by copying an existing dashboard. If you copy a public dashboard, the
copy is private.
Syntax
dashboard.copy(newName);
where dashboard is a Dashboard object.
Return value
No return value.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Dashboard.NameValidationError Either a dashboard with the same name already exists or the specified name
is not valid.
Dashboard.NoPermission The dashboard cannot be copied or you do not have permission to copy it.
Example
getLayout method
Retrieves the layout of a dashboard.
Syntax
dashboardLayout = dashboard.getLayout();
where dashboard is a Dashboard object.
Returns
A dashboard layout.
Exceptions
The getLayout method does not throw exceptions.
Example
createEmbeddedLinkUrl method
Creates a link to the current view of the dashboard, including the widgets displayed and the
scenario, filter, site, and other data display settings specified. This link can be sent to users and
groups.
When you create a link, it is added to the links collection.
Syntax
link = Dashboard.createEmbeddedLinkUrl();
where Dashboard is a dashboard object.
Returns
A String value.
Exceptions
The createEmbeddedLinkUrl method does not throw exceptions.
Example
createLink method
Creates a link in a collaboration to the current view of a dashboard, including the widgets
displayed and with the scenario, filter, site, and other data display settings specified.
When you create a link, it is added to the links collection.
Syntax
link = Dashboard.createLink();
where Dashboard is a dashboard object.
Exceptions
The createLink method does not throw exceptions.
Example
Widget objects are used to display data in dashboards. All widgets available to the script are
contained in the widgets collection.
In addition to the resource object properties, the Widget object has the following properties.
worksheetId String The worksheet identifier for the worksheet the widget is defined in.
controlSettings Object A ControlSettings object that defines the data display settings for the widget.
variables Object A collection of NameValueDisplayValue objects that define the variables and
values used in the widget. For list variables, these must be the display values that
correspond to list items.
displayValue String The value displayed for the specified value. This value should be used for all
processes that include the variable.
Method Description
get (key) Retrieves a widget object
exists (widget) Determines whether the specified widget exists in the collection
exists method
Determines if a specific widget exists. However, because Maestro supports multiple users
working with the same resources, a user might delete the specified widget after this method
runs. If you are using this method to test whether a widget exists, you should still catch a
NotFound exception.
Syntax
widgetExists = rapidResponse.widgets.exists({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the widget exists
l false if the widget does not
exist
Exceptions
The exists method can throw the following exceptions.
Example
get method
Retrieves an instance of a widget object.
Syntax
widgetObject = rapidResponse.widgets.get({name:'Name', scope:'Public or
Private'});
Parameter Description
name The name of the widget to retrieve.
You can also retrieve the widget using its id property, if you know it or can access it.
widget = rapidResponse.widgets.get(id);
where id is a string that contains the widget's id property, which is a GUID consisting of upper
and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A widget object
Exceptions
The get method can throw the following exceptions.
Widget.NotFound The specified widget does not exist or you do not have access to it.
Example
Method Description
give(newOwner) Gives the widget to the specified user.
makePublic() Changes the scope of a widget to "Public", which is the equivalent of sharing the widget.
Public widgets can be accessed by administrators and users and groups with access.
You can also share a widget with a particular user or group using the accessControlList
collection's add method.
give method
Gives a widget to the specified user.
Syntax
widget.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Widget.NotFound The specified widget does not exist.
Widget.NonUniqueName The specified user already owns a widget with the same name as the one you are
giving.
Example
makePublic method
Changes the scope of the specified widget from "Private" to "Public", which shares the widget
and allows other users to access it. This method does not specify other users or groups to share
the widget with, so it is available to only you and administrators.
If you call this method on a variable that represents a widget, you must ensure you assign the
returned public widget to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the widget with specific users and groups using the accessControlList
collection's add method.
Syntax
publicWidget = widget.makePublic();
Return value
A Widget object that represents the same widget with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
Widget.NotFound The specified widget does not exist.
Widget.NonUniqueName A shared widget with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a widget.
Syntax
widget.rename(newName);
where widget is a Widget object.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Widget.NameValidationError Either a widget with the same name already exists or the specified name is not
valid.
Widget.NoPermission The widget cannot be renamed or you do not have permission to rename it.
Example
copy method
Creates a new widget by copying an existing widget. If you copy a public widget, the copy is
private.
Syntax
widget.copy(newName);
where widget is a Widget object.
Return value
No return value.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Widget.NameValidationError Either a widget with the same name already exists or the specified name is not
valid.
Widget.NoPermission The widget cannot be copied or you do not have permission to copy it.
Example
getAttachments method
Retrieves images and linked files that are defined in a text widget. Only images that have been
uploaded and attached, not those from the image library, are returned by this method.
Syntax
widget.getAttachments();
where widget is a Widget object.
Return value
An object that contains linked images and files, with the following properties.
Property Description
name The linked file's name.
Exceptions
The getAttachments method does not throw exceptions.
The Form object defines a form. A form is a customized user interface for input values that
executes an underlying script when run. Form objects are contained in the forms collection.
Form objects have the same properties as Resource objects .
forms collection
The forms collection contains all forms available to the user running the script. The forms
collection implements the following resource collection methods.
Method Description
get (key) Retrieves a form.
exists (form) Determines whether the specified form exists in the collection.
Syntax
rapidResponse.forms.get( {name, scope} );
You can also retrieve the form using its id property, if you know it or can access it.
form = rapidResponse.forms.get(id);
where id is a string that contains the form's id property, which is a GUID consisting of upper
and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Return value
A Form object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A null value was passed to a parameter.
Form.NotFound The specified form does not exist or you do not have access to it.
Example
Syntax
rapidResponse.forms.exists({name: "Name", scope:"Public or Private"});
Return value
Type Description
Boolean l true if the form exists
l false if the form does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
Syntax
rapidResponse.forms.remove(form);
Return value
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Form.NoPermission You do not have permission to delete the specified form.
Example
makePublic() Changes the scope of a form to "Public", which is the equivalent of sharing the form. Public forms
can be accessed by administrators and users and groups with access.
You can also share a forms with a particular user or group using the accessControlList collection's
add method.
Method Description
okCancelNotice(message, okAction, cancelAction) Creates a notice with OK and Cancel buttons.
yesNoCancelNotice(message, yesAction, noAction), Creates a notice with Yes, No, and Cancel buttons.
cancelAction
give method
Gives a form to another user.
Syntax
form.give(newOwner);
where form is a Form object.
Return value
No return value.
Exception Description
form.NotFound The specified form does not exist.
Example
makePublic method
Changes the scope of the specified form from "Private" to "Public", which shares the form and
allows other users to access it. This method does not specify other users or groups to share the
form with, so it is available to only you and administrators.
If you call this method on a variable that represents a form, you must ensure you assign the
returned public form to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the form with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared form, and you can allow other users and groups to access
a shared form.
Syntax
publicForm = form.makePublic();
where form is a Form object.
Return value
A Form object that represents the same form with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Form.NonUniqueName A shared form with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a form.
Syntax
form.rename(newName);
where form is a Form object.
Return value
No return value.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Form.NameValidationError Either a form with the same name already exists or the specified name is not valid.
copy method
Creates a new form by copying an existing form.
Syntax
form.copy(newName);
where form is a Form object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Form.NameValidationError Either a form with the same name already exists or the specified name is not valid.
Form.NoPermission The form cannot be copied or you do not have permission to copy it.
Examples
This example copies a form.
This example copies a form, and then gives the copy to a user who will modify it.
okCancelNotice method
Creates a notice with OK and Cancel buttons.
Syntax
form.okCancelNotice(message, okAction, cancelAction);
where form is a Form object.
okAction Object The action performed when the OK button is clicked or tapped.
cancelAction Object The action performed when the Cancel button is clicked or tapped.
This parameter is optional. If a value is not provided, the default value is
DismissNoticeAction.
Return value
A Notice object.
Exceptions
No exceptions.
Examples
This example creates a notice that displays a warning message about overstocked inventory
where the user can click OK to run the "Disregard" script action to continue or click Cancel to run
the "Abort" script action, which cancels the action.
In this example, the Disregard function can ignore the overstock condition and commit the
working scenario, and can be defined as follows:
function Disregard() {
var form = rapidResponse.scriptArguments["#Form"];
var scenario = rapidResponse.scenarios.get(form.data.scenarioId);
var name = scenario.name;
scenario.commit();
//Respond with an auto-closing message
return form.response ({
notice: form.autoCloseNotice("Committed the " + name + " scenario.",
"Success")
});
}
The Abort function can then delete the working scenario, and can be defined as follows:
function Abort() {
var form = rapidResponse.scriptArguments["#Form"]
rapidResponse.scenarios.remove(form.data.scenarioId);
//Respond with an auto-closing message
return form.response ({
notice: form.autoCloseNotice("Deleted the working scenario", "Success")
});
}
yesNoNotice method
Creates a notice with Yes and No buttons.
yesAction Object The action performed when the Yes button is clicked or tapped.
noAction Object The action performed when the No button is clicked or tapped.
This parameter is optional. If a value is not provided, the default value is
DismissNoticeAction.
Return value
A Notice object.
Exceptions
No exceptions.
Example
This example creates a notice that displays a warning message about being below a base
threshold for inventory, where the user can click Yes to run the "Continue" script action to
continue executing the script, or click "No" to cancel the action.
return myForm.response({
notice: myForm.yesNoNotice("You are below the inventory base threshold. Do
you want to continue?", myForm.runScriptAction("Continue"),
myForm.closeFormAction()),
data: {
scenarioId: myScenario.id
}
});
The Continue function in this example could commit the working scenario, and can be defined as
follows:
function Continue() {
yesNoCancelNotice method
Creates a notice with Yes, No, and Cancel buttons.
Syntax
form.yesNoCancelNotice(message, yesAction, noAction, cancelAction);
where form is a Form object.
yesAction Object The action performed when the Yes button is clicked or tapped.
noAction Object The action performed when the No button is clicked or tapped.
cancelAction Object The action performed when the Cancel button is clicked or tapped.
This parameter is optional. If a value is not provided, the default value is
DismissNoticeAction.
Return value
A Notice object.
Exceptions
No exceptions.
Example
This example creates a notice that displays a message about an option to automatically generate
a new product number for the product you are inputting, where the user can click Yes to perform
the "Yes" script action to automatically generate the number, click No to dismiss the form notice
and specify different input values, or "Cancel" to cancel the action.
In this example, the Yes function can generate a product number based on the user running the
script and a random number between 1 and 1000, and can be defined as follows.
function Yes() {
var form = rapidResponse.scriptArguments["#Form"]
var prodNumber = rapidResponse.loggedOnUser.id + Math.floor((Math.random()
* 1000)+1);
return form.response ({
notice: form.autoCloseNotice("Created product number" + prodNumber,
"Success")
});
}
The response that displays the notice does not require a data element because the function
does not require any data from the script.
autoCloseNotice method
Creates a notice on the form that briefly displays and then automatically closes
Syntax
form.autoCloseNotice(message, type);
where form is a Form object.
type String Optionally, the type of notice to create. This value can be Error, Info, Question,
Success, or Warning. If not specified, the Success type is displayed.
For more informaiton about notice types, see " Notices" on page 80.
Exceptions
No exceptions.
Example
This example creates a notice that displays a message informing users that an activity in the
S&OP cycle has finished. The notice then automatically closes.
myForm.autoCloseNotice("Activity finished.")
This example creates a warning message informing users records were inserted by the script and
informing them that records inserted into a keyless table might not be unique. The notice then
automatically closes.
formDependencies collection
The formDependencies collection contains all forms that a workbook depends on, represented
as FormDependency objects.
The dependencies collection implements only the collection iteration functions. For more
information, see "Resource collections" on page 107.
FormDependency object
FormDependency objects define forms that a workbook depends on for functionality. The
FormDependency object has the following properties.
Action objects
The Action object defines the type of action performed by a form. It is associated with a Button
object and is used to specify the action that takes place when users press the button in a notice
on the form.
The Action object has the following property.
dismissNoticeAction method
The dismissNoticeAction method defines an action that closes the form notice. The form remains
open. To close the form, the closeFormAction method must be invoked. For more information,
see "closeFormAction method" on page 396.
Syntax
myForm.dismissNoticeAction()
Returns
No return value.
Example
runScriptAction method
The main script function is executed when the form is run. The runScriptAction method runs the
script again and executes a function.
Syntax
myForm.runScriptAction(function)
Argument Description
function The name of the script function to run.
Returns
No return value.
Exceptions
No exceptions.
Examples
This example performs a function named commit if the user clicks 'Yes' in the form response. The
response defines the data to be sent to the commit function, which in this case is the scenario
specified in the workingScenario variable.
return myForm.notice({
notice = myForm.yesNoNotice(
function commit(){
const Form = rapidResponse.scriptArguments["#Form"];
var scenario = Form.data.Scenario;
// get the scenario and then commit it
scenarioCommit = rapidResponse.scenarios.get({
name: scenario.name,
scope: scenario.scope
});
scenarioCommit.commit();
}
closeFormAction method
The closeFormAction method defines an action that closes the form.
Syntax
myForm.closeFormAction()
Returns
No return value.
Exceptions
No exceptions.
Response object
The Response object defines the response returned from the script to a form. The form
processes the response and, if specified in the object, it also displays a notice.
data Object Optional data that might be sent back in the response if the users clicks or taps a
button that performs a runScriptAction action. For more information, see
"runScriptAction method" on page 395.
You can specify the data to pass back to the script action as a list of name:value pairs.
For example, to pass a variable that contains a scenario, you could define this object
as:
data:{
scenario: scenarioVariable
}
ControlMessage object
The ControlMessage object defines a customized message that displays on a form control.
type String The type of notice. This value can be Error, Info, Question, Success, or Warning.
autoClose Boolean If true, no buttons display and the notice displays briefly before automatically
closing.
buttons Object An array of Button objects that define the action performed by the script.
The Button object defines a customized button on the Notice and has the following properties
action Object A collection of Action objects that define the script action performed when the notice
button on the form is clicked or tapped.
Each button in a form notice can perform an action, which you can define.
ErrorResponse object
The ErrorResponse object defines the error response return from the script to a form.
controlMessages Object An array of ControlMessages objects that define customized messages that
display on form controls.
The Scorecard object defines a scorecard. A scorecard is a type of report that allows users to
compare scenarios' performance on key business metrics. Scorecard objects are contained in the
scorecards collection.
Scorecard objects have the same properties as Resource objects.
Scorecards collection
The scorecards collection contains all scorecards available to the user running the script. The
scorecards collection implements the following resource collection methods.
Method Description
get (key) Retrieves a scorecard.
exists (scorecard) Determines whether the specified scorecard exists in the collection.
get method
Retrieves an instance of a scorecard.
You can also retrieve the scorecard using its id property, if you know it or can access it.
scorecard = rapidResponse.scorecards.get(id);
where id is a string that contains the scorecard's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Return value
A Scorecard object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A null value was passed to a parameter.
Scorecard.NotFound The specified scorecard does not exist or you do not have access to it.
Example
Syntax
rapidResponse.scorecards.remove(scorecard);
Return value
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Scorecard.NoPermission You do not have permission to delete the specified scorecard.
Example
exists method
Determines whether a specific scorecard exists in the collection. However, because Maestro
supports multiple users working with the same resources, a user might delete the specified
scorecard after this method runs. If you are using this method to test whether a scorecard exists,
you should still catch a NotFound exception.
Syntax
rapidResponse.scorecards.exists({name: "Name", scope:"Public or Private"});
Return value
Type Description
Boolean l true if the scorecard exists
l false if the scorecard does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
makePublic() Changes the scope of a scorecard to "Public", which is the equivalent of sharing the scorecard.
Public scorecards can be accessed by administrators and users and groups with access.
You can also share a scorecard with a particular user or group using the accessControlList
collection's add method.
give method
Gives a scorecard to the specified user.
Syntax
scorecard.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Scorecard.NotFound The specified scorecard does not exist.
Example
makePublic method
Changes the scope of the specified scorecard from "Private" to "Public", which shares the
scorecard and allows other users to access it. This method does not specify other users or groups
to share the scorecard with, so it is available to only you and administrators.
If you call this method on a variable that represents a scorecard , you must ensure you assign the
returned public scorecard to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the scorecard with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared scorecard , and you can allow other users and groups to
access a shared scorecard.
Syntax
publicScorecard = scorecard.makePublic();
Return value
A Scorecard object that represents the same scorecard with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Scorecard.NonUniqueName A shared scorecard with the same name as the one you are sharing already exists.
Example
rename method
Changes the name of a scorecard.
Syntax
scorecard.rename(newName);
where scorecard is a Scorecard object.
Return value
A Scorecard object with the new name.
Exceptions
The rename method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Scorecard.NameValidationError Either a scorecard with the same name already exists or the specified name is
not valid.
Example
copy method
Creates a new scorecard by copying an existing scorecard. If you copy a public scorecard, the
copy is private.
Syntax
scorecard.copy(newName);
where scorecard is a Scorecard object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Exception Description
ArgumentError A blank string, invalid string, or null value was specified for the newName
parameter.
Scorecard.NoPermission The scorecard cannot be copied or you do not have permission to copy it.
Example
Collaboration objects allow you to communicate, share simulated data, and compare solutions in
a single interface. Collaboration objects are contained in the collaborations collection.
collaborations collection
The collaborations collection contains all collaborations available to the user running the script.
The collaborations collection implements the following resource collection methods.
Method Description
get (collaborationId) Retrieves the specified collaboration.
get method
Retrieves an instance of a collaboration.
Syntax
rapidResponse.collaborations.get( collaborationId );
Example
remove method
Deletes a collaboration. This function requires user administration or system administration
permission to use.
Syntax
rapidResponse.collaborations.remove(collaborationId)
Return value
No return value.
Example
In this example, the script retrieves information about collaborations from the Collaborations
worksheet (id=DeleteCollaborations) in the Collaborations workbook. It then deletes
collaborations that have not been accessed in the last 10 days. The value required for the
remove method's collaborationId parameter can be found in the first column in the worksheet,
which is hidden.
collaborationScenario collection
The collaborationScenario object defines the scenarios in the collaboration and has the following
property.
Method Description
get(key) Retrieves a scenario object in a collaboration.
add(key) Shares the scenario with participants in the specified collaboration by adding the scenario to the
collection.
get method
Retrieves an instance of a scenario in a collaboration.
Return value
A Scenario object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A null value was passed to a parameter.
Example
Note: The term "public" is used for shared scenarios in scripting because, in much earlier
versions, scenarios were referred to as private and public, rather than private and shared.
"Public" is retained in reference to scenario scope to avoid breaking users' scripts.
has method
Determines if collaboration has a specific scenario. However, because Maestro supports multiple
users working with the same resources, a user might delete the specified scenario from the
collaboration after this method runs. If you are using this method to test if a scenario exists in a
collaboration, you should still catch a NotFound exception.
Syntax
rapidResponse.collaborationScenario.has({name: "Name", scope: "Public or
Private"});
Returns
Type Description
Boolean l true if the scenario is in the collaboration.
l false if the scenario is not in the
collaboration.
Exceptions
The has method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
Note: The term "public" is used for shared scenarios in scripting because, in earlier
versions, scenarios were referred to as private and public, rather than private and shared.
"Public" is retained in reference to scenario scope to avoid breaking users' scripts.
add method
Shares the scenario with participants in a specified collaboration by adding the scenario to the
collection.
Syntax
rapidResponse.collaborationScenario.add(principal, level);
level String Determines what level of access collaboration participants have to the scenario. Can
be "View only" or "Modify".
Returns
No return value.
Exceptions
The add method can throw the following exceptions.
Exception Description
ArgumentError An invalid or null value was specified for a parameter.
AccessControl.InvalidPermissionLevel A value other than "View" or "Modify" was specified for the level
parameter.
Scenario.NonUniqueName A shared scenario with the same name as the one you are sharing
already exists.
Example
To share a scenario:
remove method
Deletes the specified scenario object from the collaboration. You can only delete scenarios that
you own and you must own all the scenario's children.
Return value
No return value.
Example
rapidResponse.collaborationScenario.remove({name:"Approved Actions",
scope:"Public"});
setProperties method
Specifies the scenario property values for scenarios added to a collaboration. This method allows
you to modify the specified property values after retrieving a Scenario object.
If you specify values for multiple properties in a single call, the method succeeds only if all
properties are set successfully. If any property cannot be set, the method fails and no values are
changed.
Syntax
collaborationScenarios.setProperties( {shareLevel: 'None/View/Modify'} );
Return value
No return value.
Exception Description
ArgumentException A parameter is missing or a null value was passed to a parameter.
setProperties.InvalidPermissionLevel A value other than "None", "View", or "Modify" was specified for the
shareLevel parameter.
Example
responsibilities collection
The responsibilities collection contains all Responsibility objects the user running the script has
access to. The responsibilities collection implements the following resource collection methods.
Method Description
get({name, scope}) Retrieves the specified responsibility.
The responsibilities collection also implements the collection indexing and iteration functions. For
more information, see "Collection indexing" on page 108.
get method
Retrieves a Responsibility object.
Syntax
responsibility = rapidResponse.responsibilities.get({name, scope});
You can also retrieve the responsibility using its id property, if you know it or can access it.
responsibility = rapidResponse.responsibilities.get(id);
where id is a string that contains the responsibility 's id property, which is a GUID consisting of
upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A Responsibility object.
Exceptions
The get method can throw the following exceptions.
Exception Description
Responsibility.NotFound The specified responsibility does not exist or the user does not have access to it.
Example
Syntax
exists = rapidResponse.responsibilities.exists({name: "Name", scope: "Public
or Private"});
Returns
Type Description
Boolean l true if the responsibility exists
l false if the responsibility does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
Method Description
give Gives the responsibility to the specified user.
(newOwner)
makePublic() Changes the scope of a responsibility to "Public", which is the equivalent of sharing the
responsibility. Public responsibilities can be accessed by administrators and users and groups
with access.
You can also share a responsibility with a particular user or group using the accessControlList
collection's add method.
give method
Gives a responsibility to the specified user.
Syntax
responsibility.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Responsibility.NonUniqueName The specified user already owns a responsibility with the same name as the
one you are giving.
Example
makePublic method
Changes the scope of the specified responsibility from "Private" to "Public", which shares the
responsibility and allows other users to access it. This method does not specify other users or
groups to share the responsibility with, so it is available to only you and administrators.
If you call this method on a variable that represents a responsibility, you must ensure you assign
the returned public responsibility to the same variable. Otherwise, the variable retains the scope
it was created with.
You can also share the responsibility with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared responsibility, and you can allow other users and groups to
access a shared hierarchy.
Syntax
publicResponsibility = responsibility.makePublic();
Return value
A Responsibility object that represents the same responsibility with its scope changed to
"Public".
Exceptions
The makePublic method can throw the following exceptions.
Responsibility.NonUniqueName A shared responsibility with the same name as the one you are sharing
already exists.
Example
The Workflow object defines workflows that build out automated processes in Maestro. All
workflows available to the user running the script are contained in the workflows collection.
Workflow objects have the same properties as Resource objects.
workflows collection
The workflow collection contains all the workflow objects available to the user running the script.
The workflows collection implements the following resource collection methods:
Method Description
get(key) Retrieves a workflow object.
get method
Retrieves a workflow object, which allows the workflow to be used in other methods and
processes.
Syntax
workflow = rapidResponse.workflows.get({name, scope});
You can also retrieve the workflow using its id property, if you know it or can access it.
workflow = rapidResponse.workflows.get(id);
Returns
A Workflow object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was passed to the method.
Workflow.NotFound The specified workflow does not exist or you do not have access to it.
Example
exists method
Determines whether a specific workflow exists. However, because Maestro supports multiple
users working with the same resources, a user might delete the specified workflow after this
method runs. If you are using this method to test whether a workflow exists, you should still
catch a NotFound exception.
Syntax
workflowExists = rapidResponse.workflows.exists({name: "Name", scope:
"Public or Private"});
Returns
Type Description
Boolean l true if the workflow exists
l false if the workflow does not
exist
Exceptions
The exists method can throw the following exceptions.
Exception Description
ArgumentError One of the following has occurred:
l The resource parameter is missing a name or scope
value.
l The scope value specified is not "Private" or "Public".
Example
remove method
Deletes a workflow from the server, which also removes it from the workflows collection.
Deleted workflows are no longer available to any user or process, and you can only delete
workflows you own or have permission to manage.
Syntax
rapidResponse.workflows.remove(name);
Exceptions
The remove method can throw the following exceptions.
Exception Description
Workflow.NoPermission You do not have permission to delete the specified workflow.
Example
Method Description
give(newOwner) Changes the owner of the workflow.
makePublic() Changes the scope of the workflow to "Public", which is the equivalent of sharing the resource.
Public resources can be accessed by administrators and users and groups who have been
granted access.
give method
Gives a workflow to a specified user. You can only give resources to individual users, not groups
of users. For more about users and groups, see the Maestro Administration Guide.
Syntax
workflows.give(newOwner);
Return value
No return value.
Exceptions
The give method can throw the following exceptions.
Exception Description
Workflow.NotFound The specified workflow does not exist.
Workflow.NonUniqueName The specified user already owns a workflow with the same name as the one you
are giving.
Example
makePublic method
Changes the scope of the specified workflow from "Private" to "Public", which shares it with
administrators. This method does not specify which users or groups to share the workflow with,
so it is only available to you and administrators. To share the workflow with specific users and
groups, use the accessControlList collection's add method.
If you call this method on a variable that represents a workflow, you must ensure you assign the
returned public workflow to the same variable. Otherwise, the variable retains the scope it was
created with.
Return value
A Workflow object that represents the same workflow with its scope changed to "Public".
Exceptions
The makePublic method can throw the following exceptions.
Exception Description
Workflow.NotFound The specified workflow does not exist.
Example
rename method
Changes the name of a workflow.
Syntax
workflows.rename(newName);
Return value
A Workflow object with the new name.
Exceptions
The rename method can throw the following exceptions.
Workflow.NameValidationError Either a workflow with the same name already exists or the specified name is
not valid.
Workflow.NoPermission The workflow cannot be renamed or you do not have permission to rename it.
Example
copy method
Creates a new workflow by copying an existing workflow and giving it the name you specify in
the method. If you copy a public workflow, the copy created is private.
Syntax
workflows.copy(newName);
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
Workflow.NameValidationError Either a workflow with the same name already exists or the specified name is
not valid.
Workflow.NoPermission The workflow cannot be copied or you do not have permission to copy it.
Example
startExecution method
The startExecution method runs a specified workflow.
Syntax
workflows.startExecution[(inputVariables)]
Return value
No return value.
Exceptions
The startExecution method can throw the following exceptions.
InvalidValue The value of an input variable provided is not valid. For example, the value for a
Boolean variable is a value other than "true" or "false".
ScenarioNotFound The value provided for a scenario input variable does not map to a scenario that the
user has access to.
ScenarioNameNotScoped The value provided for a scenario input variable is not scoped with the ?private: or
?public: prefix.
Examples
Execute the startExecution method without optional input variables:
workflows.startExecution();
workflows.startExecution(variables);
These method both return a query object, which contains the data returned from the specified
table. See "query object" on page 438.
execute method
Returns multiple records from the query in the form of data rows and column information. The
object returned by the execute method must be closed using the close method.
Syntax
rapidResponse.query.execute({scenario, table, filter, queryParameters,
columns})
where
table String The table that the query will access to return the data. This must be the fully-
qualified table name including namespace, in the format namespace::table.
queryParameters Object The queryParameters object that contains acceptable key values.
Return Value
Returns a query object.
Exceptions
The execute method can throw the following exception:
Exception Description
BadNumberOfArgumentsException More than one argument is specified.
Example
In this example, the script multiplies the standard unit cost value by 15%.
query.columns.forEach(column => {
rapidResponse.console.writeLine(column.id + ": " + column.dataType);
});
query.rows.forEach(row => {
var cell = row.cells.get("StdUnitCost");
cell.setValue(cell.value * 1.15);
});
query.commit();
query.close();
executeSingleton method
Returns a single record from the query in the form of a data row and column information. This
method automatically closes and does not require the close method.
Syntax
rapidResponse.query.executeSingleton({scenario, table, filter,
queryParameters, columns})
where
table String The table that the query will access to return the data. This must be the fully-
qualified table name including namespace, in the format namspace::table.
queryParameters Object The queryParameters object that contains acceptable key values.
Return Value
Returns a cellsCollection object. If there is no data, a value of null is returned.
Exceptions
The executeSingleton method can throw the following exception:
Exception Description
BadNumberOfArgumentsException More than one argument is specified.
Example
In this example, the script gets data for a single record (name = AC001).
queryParameters object
The queryParameters object contains additional values to define the data retrieved by the query.
If used in the query, these can define limits to the number of records returned, deifne a source
for the data, or contain additional parameters that you define.
The queryParameters object has the following properties:
source String String that you specify that is included in logs. Enables you to track this query in the
log when multiple queries are run in a script.
variables Object Defines variables that are used to filter or control the data returned. These are
specified in key:value pairs.
query object
Provides access to a data set returned by a Maestro query.
The query object has the following properties:
rows Object A collection of row objects that define the rows returned by the query. See "rows
collection and Row objects" on page 442.
status String The status of the query. Any error that occurs during execution of the query displays
here.
Method Description
close Closes the query after it has finished running.
commit Commits data changes from a scenario to its parent scenario in the query.
close method
Closes the query after it has finished running. Queries that are closed are removed from memory
and cannot be referenced.
The execute object must be closed and it is recommended that you close your queries as soon as
possible to free up memory for other processes.
Syntax
query.close()
where query is a query object.
Returns
No return value
Exceptions
No exceptions.
query.close();
commit method
Saves the values in the current query to the scenario identified in the query. This method only
applies if values have been changed in any of the cells or if rows were added or deleted in the
query. You must have permission to edit the scenario and it must be up to date when the query
is run.
If you do not call this method, any changes you make to the query data are not saved.
Syntax
query.commit()
where query is a query object.
Returns
No return value.
Exceptions
The commit method can throw the following exceptions:
Exception Description
Scenario.NoPermission Either you do not have permission to commit the specified scenario or the scenario
is a change data capture scenario and cannot be committed.
Scenario.NonRootOnly The specified scenario is the root scenario, which cannot be committed.
Scenario.HasOpenQueries The scenario has other queries running on it, or is being used in a workbook or
scorecard.
Example
In the following example, the script commits a scenario after multiple rows have been deleted.
dataType String The type of data in the column. Only Integer, Quantity, Money, String, Date, and
DateTime data types support editing.
Method Description
deleteRow() Deletes a single row from the query.
You can implement the forEach() standard JavaScript function to iterate over items in the
collection. See "Collection iteration functions" on page 109.
cells Object A collection of cell objects that contain all of the cells in that row of data. See "cells
collection and Cell objects" on page 443.
Method Description
get() Retrieves the cell as an object.
You can also implement the forEach() standard JavaScript function to iterate over items in the
collection. See "Collection iteration functions" on page 109.
The number of cells in a row is defined by the number of columns in the columns collection.
Method Description
setValue() Changes the value of the data in the cell. This value must by compatible with the data type of the
cell. The Integer, Quantity, Money, String, Date, and DateTime data types support editing.
Method Description
get() Retrieves the specified cell as an object.
Method Description
setValue() Specifies a value for a cell.
Method Description
deleteRow() Deletes a single row from the query.
get method
Retrieves a cell within a query data row, allowing you to manipulate the cell or retrieve its value.
Syntax
cell = cellCollection.get()
Returns
Returns the specified cell as an object.
Exceptions
The get method can throw the following exception:
Exception Description
ArgumentError A blank string or null value was passed to the method.
Example
This example gets the value from the StdUnitCost column in a query row.
This example reuns a query on the Part table, and then returns the value from the StdUnitCost in
the 10th row.
query.close()
return cell.value;
This example returns the greatest value in the StdUnitCost column. This example uses a
collection iteration function to compare each row's StdUnitcost value and return the greatest
value from the data set.
var greatest = 0;
query.rows.forEach(row => {
var cell = row.cells.get("StdUnitCost");
if (cell.value > greatest) {
greatest = cell.value;
}
query.close()
return greatest;
setValue method
Specifies a value to insert for a cell in a row returned by a query. You can use this to define row
values to insert using the insertRow method. You can specify a value for any column in the row,
and the values you specify must be valid for the data type of the column you insert it into.
You can also use this method to copy values between tables or worksheets. You can open a
query on one table and use the get method to get the value from a table, and the setValue
method to write that value into the other table. This might require you to format the value,
depending on the data type. Data loaded from a Maestrotable are stored using Javascript data
types, which might not match the destination field exactly. Specifically, the Javascript Date type
can be formatted to save either a Date, Time, or DateTime value in Maestro.
Syntax
cell.setValue(newValue);
where newValue is the value to set the cell value to. This can be a constant, variable, or
calculation.
Returns
No return value.
Exceptions
The setValue method does not throw exceptions. However, if an invalid data type is specified for
a field, a query error is returned when the query.commit() method is called.
Examples
This example modifies all returned values in a column.
query.rows.forEach(row => {
var cell = row.cells.get("StdUnitCost");
cell.setValue(cell.value * 1.15);
});
query.commit();
query.close();
This example specifies values for each cell to be inserted as a new row using the insertRow()
method .
This example copies values from one DateTime field in a custom table to another DateTime field
in that table.
query.rows.forEach(row => {
var cell = row.cells.get("ActiveDate");
var setCell = row.cells.get("StartDate");
setCell.setValue(cell.value);
});
query.commit();
query.close();
This example copies values between tables, using a query for each table. This example uses
iteration functions over both queries' rows collections to locate matching values in one field,
which then copies the corresponding value from the Earliest field from the custom ActivityDetails
table to the StartDateTime field on the custom PartDetails table.
partDetailQuery.rows.forEach(pdRow => {
activityDetailQuery.rows.forEach(aRow => {
if (pdRow.cells.get("Activity").value == aRow.cells.get
("Activity").value) {
pdRow.cells.get("StartDate").setValue(aRow.cells.get
("Earliest").value);
}
})
});
activityDetailQuery.close();
partDetailQuery.commit();
partDetailQuery.close();
In this example, because no changes were made to the ActivityDetail table, it does not need to
be committed.
If necessary, you can also perform data type conversions. This example is similar to the previous,
but uses a Date field from the Part table to populate a custom DateTime field, using the
JavaScript Date object's toISOString() method to convert the Date value to a DateTime in the ISO
format.
partDetailQuery.rows.forEach(pdRow => {
partQuery.rows.forEach(partRow => {
if (pdRow.cells.get("Name").value == partRow.cells.get("Name").value &&
pdRow.cells.get("Site").value == partRow.cells.get("Site").value) {
pdRow.cells.get("StartDate").setValue(new Date(partRow.cells.get
("Needed").value.toISOString()));
}
})
});
partQuery.close();
partDetailQuery.commit();
partDetailQuery.close();
deleteRow method
Deletes a single row of data from the query.
This method must be followed by the commit method for the data to be saved to the server. See
"commit method" on page 440.
rowIndex Integer The row to delete in the data that was returned by the query.
Returns
No return value
Exceptions
The deleteRow method can throw the following exception:
Exception Description
ArgumentException The number of rows is less than 0 or greater than the number of rows in the query.
Example
In this example, the script deletes any rows with the part name AC001 or AC002.
Syntax
query.deleteRows(startRowIndex, endRowIndex)
where query is a query object.
endRowIndex Integer The last row to delete. This value is set in relation to the first row returned by the
query.
startRowIndex Integer The first row to delete. This value is set in relation to the first row returned by the
query.
Returns
No return value
Exceptions
The deleteRows method can throw the following exceptions:
Exception Description
ArgumentException One of the following has occurred:
l The number of rows is less than 0 or greater than the number of rows in the
query.
l The end index value is greater than the start index value.
Example
In this example, the script deletes all rows returned by the query.
insertRow method
Inserts one row of data into the query. To successfully insert a row, the query must include
columns for all key fields in the table and each cell in the new row must have data specified for it.
This method must be followed by the commit method for the data to be saved to the server. See
"commit method" on page 440.
Syntax
query.insertRow()
where query is a query object.
Returns
Returns a row object for each new row.
Exceptions
No exceptions
Example
In the example, the script inserts a new row for AC_TEST at the site CM2 with a standard unit cost
of 45. To ensure the new record is valid, include a buyer code and planner code .
query.commit();
query.close();
This example assumes there is a BuyerCode value DK and a PlannerCode value CG at site CM2. If
these records do not exist, the query fails with an invalid reference. If necessary, you could
execute queries on these tables t insert the required rows.
processTemplates collection
The processTemplates collection contains all ProcessTemplate objects the user running the script
has access to. The processTemplates collection implements the following resource collection
methods.
Method Description
get({name, scope}) Retrieves the specified process.
The processTemplates collection also implements the collection indexing and iteration functions.
For more information, see "Collection indexing" on page 108.
get method
Retrieves a ProcessTemplate object.
Syntax
process = rapidResponse.processTemplates.get({name, scope});
You can also retrieve the process template using its id property, if you know it or can access it.
process = rapidResponse.processTemplates.get(id);
where id is a string that contains the process template's id property, which is a GUID consisting
of upper and lower case letters, numbers, and hyphens, in the format {8 characters}-{4
characters}-{4 characters}-{4 characters}-{12 characters}.
Returns
A ProcessTemplate object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ProcessTemplate.NotFound The specified process does not exist or the user does not have access to it.
Example
Syntax
exists = rapidResponse.processTemplates.exists({name: "Name", scope: "Public
or Private"});
Returns
Type Description
Boolean l true if the process exists
l false if the process does not
exist
Exceptions
The exists method can throw the following exception.
Exception Description
ArgumentError One of the following has occurred:
l The parameter is missing a name or scope value.
l The scope value specified is not "Private" or
"Public".
Example
Method Description
give Gives the process to the specified user.
(newOwner)
makePublic() Changes the scope of a process to "Public", which is the equivalent of sharing the process. Public
processes can be accessed by administrators and users and groups with access.
You can also share a process with a particular user or group using the accessControlList
collection's add method.
give method
Gives a process to the specified user.
Syntax
process.give(newOwner);
Return value
No return value.
Exception Description
ProcessTemplate.NotFound The specified process does not exist.
ProcessTemplate.NonUniqueName The specified user already owns a process with the same name as the one
you are giving.
Example
makePublic method
Changes the scope of the specified process from "Private" to "Public", which shares the process
and allows other users to access it. This method does not specify other users or groups to share
the process with, so it is available to only you and administrators.
If you call this method on a variable that represents a process, you must ensure you assign the
returned public process to the same variable. Otherwise, the variable retains the scope it was
created with.
You can also share the process with specific users and groups using the accessControlList
collection's add method.
Administrators can access any shared process, and you can allow other users and groups to
access a shared process.
Syntax
publicProcess = process.makePublic();
Return value
A ProcessTemplate object that represents the same process with its scope changed to "Public".
Exception Description
ProcessTemplate.NotFound The specified process does not exist.
ProcessTemplate.NonUniqueName A shared process with the same name as the one you are sharing already
exists.
Example
rename method
Changes the name of a process.
Syntax
process.rename(newName);
where process is a ProcessTemplate object.
Return value
A ProcessTemplate object with the new name.
Exceptions
The rename method can throw the following exceptions.
ProcessTemplate.NameValidationError Either a process with the same name already exists or the specified
name is not valid.
Example
copy method
Creates a new process by copying an existing process. If you copy a public process, the copy is
private.
Syntax
process.copy(newName);
where process is a ProcessTemplate object.
Return value
No return value.
Exceptions
The copy method can throw the following exceptions.
ProcessTemplate.NameValidationError Either a process with the same name already exists or the specified
name is not valid.
ProcessTemplate.NoPermission The process cannot be copied or you do not have permission to copy
it.
Example
The charting property defines a ChartEngine object, which generates charts for dashboards and
crosstab worksheets.
JsChart objects
The JsChart object defines a chart. The JsChart object has the following properties.
image String A base64-encoded String that represents an image file. This string can be displayed
as an image in an HTML document.
generate method
Creates a chart.
Note: As of Service Update 2510, this method is no longer supported in scripts. Please
contact the script author or Kinaxis Customer Support if you require further assistance.
Syntax
rapidResponse.charting.generate(definition, options)
options Object Optionally defines the dimensions of the chart. This is an object with the following
properties.
l height: The height of the chart, in pixels. This must be a positive number.
l width: The width of the chart, in pixels. This must be a positive number.
Returns
A JsChart object.
Exceptions
The generate method can throw the following exception.
Exception Description
ArgumentException One of the following has occurred.
l One or both of the parameters have not been specified, or a null value was
provided.
l An invalid chart definition was provided for the definition parameter.
l A negative value or a non-number value was provided for the options
parameter.
The integrationPlatformService property defines connections to external systems that you can
integrate with your Maestro instance. This includes a connection to the Integration Platform and
Talend Administration Center (TAC), and any external endpoints that send or receive data for use
in your Maestro processes. You can use these connections to run tasks defined on your TAC or
send real-time messages to your external systems, using either the Real-time Integration
Platform or a predefined external system endpoint.
The integrationPlatformService property defines the following methods:
Method Description
runTask(name) Runs the specified task on the Talend Administration Center.
invokeEndpointV2(endpoint, Sends a request to an external endpoint and receives user token information
method) in its response.
The integrationPlatformService property is available to run tasks on the TAC only if the
Integration Platform Service has been configured. Otherwise, a script that uses this property and
the runTask() method fails. For more information, see the Maestro Data Integration Guide.
groupId String An optional identifier used to ensure a message split into multiple parts is delivered
together. You should ensure this value is unique by constructing it from randomly-
generated components, such as a GUID.
worksheet String A worksheet identifier for the worksheet the data for this message is taken from.
test String Optionally, whether the message is being sent as a test. This property should be set to
"Y" if you are testing the message, and set to "N" otherwise.
If the test property is set to "Y", the message output is displayed in the script output
console in the script log, and the message is not sent. See "Script logging" on page 94.
sets Object[] An array of Set objects, which define a set of data records from another table to be
included in the outbound data.
The Set object represents the data from a referenced table that is included with the outbound
data. and contains the following properties:
name String A name assigned to the set, which is used in the outbound XML data to define the set.
It is recommended you set this value to the name of the table the set records are taken
from or the name of the set field in the table.
runTask method
The runTask method accesses the Talend Administration Center (TAC) and runs the specified
task. The task performs the actions defined in its underlying job, executing on the job server.
Syntax
rapidResponse.integrationPlatformService.runTask(taskName);
Returns
No return value.
Exceptions
The runTask method returns exceptions from the TAC, and does not use the
rapidResponse.Exception object. The following error conditions might occur.
l The specified task does not exist.
l The user configured for the Integration Platform Service does not have access to the
specified task.
l The Integration Platform Service is not configured.
Example
This example runs a workbook command to prepare data, and then runs the OutboundData task
on your hosted TAC. This task takes data from the workbook and prepares it to be loaded back
into the originating data source.
Syntax
var messageSent = rapidResponse.integrationPlatformService.sendMessage
(definition, data, set);
Argument Description
definition The MessageDefinition object that defines the message to send.
set Optionally, the worksheet data representing a set of related data to send to the external
destination.
Return value
An object that defines the replies for the message.
Examples
This example sends a test message that contains supply orders and associated order lines.
This example sends a message that contains supply orders. This example uses a group identifier
that is generated from two randomly-generated numbers.
getEndpointIds method
Returns a list of endpoints defined for you to use for sending requests to external systems or
services. These endpoints are defined by your Maestro administrator, and define the location
and authentication to access the corresponding system.
You can create a script that calls this method and run it periodically to ensure the endpoint you
intend to use has not changed
Syntax
endpoints = rapidResponse.integrationPlatformService.getEndpointIds();
Returns
An array of the endpoint identifiers, as strings.
Exception Description
ArgumentException An argument was passed to the method.
Examples
This example returns all endpoints your Maestro administrator has defined.
This example takes an endpoint as an argument, then retrieves endpoints and sets a variable to
that endpoint if it exists.
Syntax
parmList =
rapidResponse.integrationPlatformService.getEndpointPathParameterNames
(endpoint)
Returns
An object that contains a list of the names of all path parameters defined for the endpoint. If the
endpoint has no path parameters, returns a blank list.
Exceptions
The getEndpointPathParameterNames method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter.
Examples
var parameterList =
rapidResponse.integrationPlatformService.getEndpointPathParameterNames
("GetServiceStatus");
rapidResponse.console.writeLine(JSON.stringify(parameterList));
Note: The payloads sent using this method can be up to 50 MB, and requests sent using
this method have a 2 minute timeout.
Syntax
response = rapidResponse.integrationPlatformService.invokeEndpoint
({endpointId, method, payload, contentType, headers, parameters,
pathParameters})
method String The HTTP method to perform using the endpoint. This must be one of the
standard HTTP methods (such as GET, PUT, POST, or DELETE), and must also be a
method that is implemented by the endpoint.
payload String Optionally, a string representation of a payload to send to the endpoint. The
format of the payload should match the content type required by the endpoint.
For example, if your endpoint requires a JSON payload, the payload should be a
JSON string, which you can create by converting an object using the
JSON.stringify() method or by converting a worksheet's data to a JSON object
using the convertToJSON() method.
A payload is not required if you are using the endpoint to send a notification.
contentType String Optionally, the HTTP content type of data the payload contains, such as text/plain
or application/json.
This is required only if you specify a payload.
headers Object Optionally, custom headers or custom values for standard headers to include in
the request, specified in key:value pairs.
parameters Object Optionally, additional parameters for the request, specified in key:value pairs.
pathParameters Object Values for path variables defined for the endpoint, which are used to specify a
dynamic location at the endpoint's destination. All path parameters for an
endpoint are required, and are specified in key:value pairs.
Depending on the endpoint and the parameter, you might require a specific
value, or you might be able to pass a value from another endpoint's response.
Whether you must specify a value or pass a value requires some knowledge of the
endpoint and its requirements.
Returns
The response from the endpoint. Depending on how the endpoint is defined, this might be a
specific message, a message with a payload, or an HTTP response code (such as 200 for
successful messages or 400 for errors).
The return object has the following properties.
Property Description
status The HTTP status for the response.
response The endpoint's return message, payload, or error message if the request failed.
Exceptions
The invokeEndpoint method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter, or a value was not provided for a required path
parameter.
CalloutError An error occurred contacting the endpoint or the request timed out.
Examples
This example sends a notification to an endpoint named ServiceReady.
This example sends data from a worksheet formatted to provide data to an external service,
which has an endpoint named ExternalService defined and expects a JSON payload. The
endpoint expects each row as an object named DataRow, with the value represented as a
comma-delimited string.
This example constructs a JSON payload based on arguments and values from a single
worksheet row, and then sends it to an endpoint that defines a single HTTP method.
This example retrieves data from an endpoint named GetStatus and outputs it to the console.
This example retrieves the status from a service defined using a dynamic path parameter. In this
case, the endpoint has some specific values that can be passed for the parameter, and you must
know the one you want to use.
invokeEndpointV2 method
This method is similar to the invokeEndpoint method, but is intended to call endpoints that have
CSRF tokens for user validation, and returns the token and cookie values generated for the user
as HTTP header values along with the response for the request. Other than these additional
returned items, this method is identical to the invokeEndpoint method in its function, syntax, and
exceptions.
You must call this method using an existing endpoint, which already has the required
authentication provided. This also requires a user context for the endpoint, which is validated
using the tokens returned in the HTTP header. If you are not using an endpoint with a user
context or do not require the additional header data, you should use the invokeEndpoint
method instead.
Syntax
response = rapidResponse.integrationPlatformService.invokeEndpointV2
({endpointId, method, payload, contentType, headers, parameters,
pathParameters})
method String The HTTP method to perform using the endpoint. This must be one of the
standard HTTP methods (such as GET, PUT, POST, or DELETE), and must also be a
method that is implemented by the endpoint.
payload String Optionally, a string representation of a payload to send to the endpoint. The
format of the payload should match the content type required by the endpoint.
For example, if your endpoint requires a JSON payload, the payload should be a
JSON string, which you can create by converting an object using the
JSON.stringify() method or by converting a worksheet's data to a JSON object
using the convertToJSON() method.
A payload is not required if you are using the endpoint to send a notification.
contentType String Optionally, the HTTP content type of data the payload contains, such as text/plain
or application/json.
This is required only if you specify a payload.
headers Object Optionally, custom headers or custom values for standard headers to include in
the request, specified in key:value pairs.
parameters Object Optionally, additional parameters for the request, specified in key:value pairs.
pathParameters Object Values for path variables defined for the endpoint, which are used to specify a
dynamic location at the endpoint's destination. All path parameters for an
endpoint are required, and are specified in key:value pairs.
Depending on the endpoint and the parameter, you might require a specific
value, or you might be able to pass a value from another endpoint's response.
Whether you must specify a value or pass a value requires some knowledge of the
endpoint and its requirements.
Returns
An object that contains the response from the endpoint, the user token, and cookie headers that
were used for the endpoint call. These are generated by the call to the endpoint to ensure the
user is authenticated and the call is valid.
The return object has the following properties.
xCSRFHeader String The X-CSRF token used for authorizing the user defined for the endpoint.
Exceptions
The invokeEndpointV2 method can throw the following exceptions.
Exception Description
ArgumentException A null value was passed to a parameter, or a value was not provided for a required path
parameter.
CalloutError An error occurred contacting the endpoint or the request timed out.
Example
This example prints the response message, X-CSRF token, and cookie names to the output
console.
This example uses the same service and saves the token and the value of the cookie named
cookieKey as variables that can be used in subsequent operations in the script.
The Link object defines a link to a resource, such as a workbook, dashboard, or form. All links you
have access to are contained in the links collection. The Link object contains only the resource
object properties, however, the scope property for links is always "Public".
The Link object has the following property.
links collection
All workbook and dashboard links that you have access to are contained in the links collection.
The links collection implements the following method, in addition to the resource collection
enumeration methods.
Method Description
get(link) Retrieves an instance of a link object.
get method
Retrieves an instance of a link object.
Returns
A Link object.
Exceptions
The get method can throw the following exceptions.
Exception Description
ArgumentError A blank or null value was passed for a parameter.
Link.NotFound The specified link does not exist or you do not have access to it.
Example
Method Description
getResource() Retrieves the resource a link opens.
getResource method
Retrieves the name of the resource a link opens.
Syntax
resourceName = link.getResource();
Returns
A String value.
Exceptions
The getResource method can throw the following exception.
Exception Description
ArgumentError A parameter was provided for the method.
Example
This example creates an instance of a link object, then retrieves the name of the resource.
However, this example returns a script run-time error because the getResource method must
be called on a Link object. The createEmbeddedLinkUrl method returns a string value, not a
link object.
createEmbeddedLinkUrl method
Creates an instance of a link object in a collaboration.
Syntax
link = rapidResponse.links.createEmbeddedLinkUrl();
Returns
A String value.
Exceptions
The create method can throw the following exceptions.
Exception Description
ArgumentError A blank or null value was passed for a parameter.
Link.NotFound The specified link does not exist or you do not have access to it.
The dateTime property provides methods for date and time calculations, and has the following
properties.
The Now DateTime constant reports the time and date when the script begins executing, and is
not updated during script execution. If you require an updated time for your script operations,
you can use the JavaScript date functions, such as Date(Date.now()).
The following dateTime methods are available.
add(date, number, calendar) Adds the specified number of calendar units to the specified date.
subtract(date, number, calendar) Subtracts the specified number of calendar units from the specified date.
difference(firstDate, lastDate, calendar) Determines the number of calendar units between two dates.
toCalendarDate method
Calculates the closest calendar date to a specified date.
Syntax
rapidResponse.dateTime.toCalendarDate(date, calendar);
calendar String The calendar the date is calculated in. This parameter is optional. If no calendar is
specified, business days are used.
Returns
Type Description
Date The calendar date closest to the specified date
Exceptions
The toCalendarDate method can throw the following exceptions.
Exception Description
ArgumentError The specified calendar does not exist.
Example
Syntax
rapidResponse.dateTime.add(date, number, calendarName);
calendarName String The calendar used to add dates. This parameter is optional. If no calendar is
specified, business days are used.
Returns
Type Description
Date The resulting date.
Exceptions
The add method can throw the following exceptions.
Exception Description
ArgumentError The specified calendar does not exist.
Example
subtract method
Subtracts the specified number of calendar units from the specified date.
Syntax
rapidResponse.dateTime.subtract(date, number, calendarName);
calendarName String The calendar used to subtract dates. This parameter is optional. If no calendar is
specified, business days are used.
Returns
Type Description
Date The resulting date.
Exceptions
The subtract method can throw the following exceptions.
Exception Description
ArgumentError The specified calendar does not exist.
Example
difference method
Reports the difference between two dates.
Syntax
rapidResponse.dateTime.difference(date, dateToSubtract, calendarName);
calendarName String The calendar used to report the difference. This parameter is optional. If no
calendar is specified, business days are used.
Type Description
Number The number of calendar periods between the two dates.
Exceptions
The difference method can throw the following exceptions.
Exception Description
ArgumentError The specified calendar does not exist.
Example
The console property defines an output console, which you can write information to debug a
script. The console property has the following method.
Method Description
writeLine(text) Writes the specified text to the output console.
writeLine method
Writes the specified text to the console output in the script log. See "Script logging" on page 94.
Syntax
rapidResponse.console.writeLine(text);
Returns
No return value
The Message object defines a message that you have received in Message Center. Message
objects are contained in the messages collection. For more information, see "messages
collection" on page 498.
The Message object has the following properties.
cc String The users, group, or email addresses that are copied on the message. Users must be
specified by user ID.
bcc String The users, group, or email addresses that are blind copied on the message. Users
must be specified by user ID.
Values specified for the to, cc, or bcc properties can be arrays of strings, or a single string with
multiple values separated by semicolons. For example,
to: ["user1", "user2"]
cc: "user3; user4"
The object defined by the attachments property contains the following properties.
content Object A ReportOutput object that represents the content of the file to be attached.
SendBroadcastMessage object
This object defines a broadcast message, which is sent to all logged-on users. This object
contains the following properties.
to String Optionally, the user or users to send the broadcast message to. If no value is specified,
the message is sent to all logged-on users. If multiple users are specified, the user
names must be separated by semicolons.
expiry Date Optionally, the date after which the message's pop-up notification is not displayed. If a
recipient signs in after the specified date, the message displays only in Message
Center. Otherwise, the user sees the pop-up notification when they sign in.
If no value is specified, the pop-up notification is displayed regardless of how old the
message is.
messages collection
The messages collection contains all Maestro messages. You can use messages to send
notifications when a script finishes or broadcast to all logged-on users. You can send messages
to any user, group, or email address. These messages are received in Message Center and can be
sent to email addresses.
Messages you send are defined using a SendMessage object, as described in "SendMessage
object" on page 497. Broadcast messages are defined using a SendBroadcastMessage object, as
described in "SendBroadcastMessage object" on page 497.
The messages collection has the following methods.
Method Description
sendMessage(message) Sends the specified message to the users, groups, or email addresses specified in
the message.
sendMessage method
Sends the specified message to the specified users or groups. Users can send messages using
this method if they do not have access to Message Center.
This method's availability is controlled by the user's visibility level. Messages include information
about the sender, so users with a visibility level of None cannot send messages. Users with a
visibility level of Limited can send messages only to users with the Full (or All) visibility level.
Syntax
rapidResponse.messages.sendMessage(message);
Returns
No return value.
Examples
This example sends a message to the members of the Buyers group.
This example sends a message to the user running the script to inform them a workbook
command has finished.
sendBroadcastMessage method
Sends a broadcast message to users. You must be an administrator to call this method.
Syntax
rapidResponse.messages.sendBroadcastMessage(message);
Returns
No return value.
Exceptions
The sendBroadcastMessage method can throw the following exceptions.
Example
rapidResponse.messages.sendBroadcastMessage(
{
subject:"RapidResponse availability",
message:"Due to hardware upgrades, the system will be sporadically
unavailable for the next day.",
expiry:new Date("2017-07-26T07:30:00")
}
);
The User object defines a user, and all users are contained in the users collection. The User object
contains the following properties.
forwardToEmail Boolean If true, messages sent to the user are also sent to their email address.
UserProfile object
The UserProfile object is used when creating a user account, and defines the properties of a user
account. The UserProfile object has the following properties.
profilePicture String A base64-encoded String that represents an image file. This string is used to
set the user's profile picture.
forwardToEmail Boolean If true, messages sent to the user are also sent to their email address.
userLicenseType String The user's type. This can be one of the following values:
l Full
l Light
l Report
l Alert
When the userLicenseType = Alert, passwords cannot be set for this user
profile because alert users do not have passwords specified in Maestro.
visibilityLevel String The user's visibility level, which determines which users can see information
about each other. The following values are valid:
l Full (corresponds to visibility level of All)
l Limited
l None
If a value is not specified for visibilityLevel, the All visibility level is assigned by
default.
isAccountDisabled Boolean If true, the user account cannot be used to sign in.
isSSOOnly Boolean If true, the user can sign in only using a single sign-in infrastructure. These
users do not have passwords specified in Maestro.
You cannot set a password for a user that has this property set to true, and
you must provide a password for the user if you set this property to false. For
users with userLicenseType = Alert, this property can only be set to false.
contactInfo Object The user's contact information. For more information, see
"ContactInfo object" on page 504.
users collection
The users collection contains all User objects defined in the system.
The users collection implements the following methods.
Method Description
create(id, profile) Creates a user account.
generatePassword() Generates a password, which can be used as the password for a new user.
The users collection also implements the resource collection iteration methods. For more
information, see "Resource collections" on page 107.
Note: If a script is run using the credentials of a user who has a visibility level of Limited
or None, the users whose information they do not have permission to see are not
included in the users collection.
create method
The create method creates a user account and adds it to the collection.
Syntax
rapidResponse.users.create(userId, Profile);
profile Object Specifies the properties of the created user, specified using a UserProfile object.
Each of the individual properties is optional.
Returns
Type Description
Object A UserCollectionObject object.
Exceptions
The create method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was specified for the id parameter.
This exception also indicates if a password is specified for a user that can
sign in only from the single sign-in infrastructure.
PasswordPolicy.TooShort If you specified a password and password policies are used, the specified
password does not meet the length requirement of the password policy.
PasswordPolicy.NotComplexEnough If you specified a password and password policies are used, the specified
password does not meet the complexity requirement of the password
policy.
PasswordPolicy.SameAsUserID If you specified a password, the specified password is the same as the
user ID.
Examples
This example creates a basic user with no permissions or resources and takes the user ID from a
script argument.
This example creates a user that can sign in only using a single sign-in infrastructure, and takes
the user ID from a script argument.
generatePassword method
The generatePassword method creates a random-generated and cryptographically strong
password that can be used to set the password for a user account.
Syntax
password = rapidResponse.users.generatePassword();
Returns
A String value that contains the password.
Examples
This example generates a password.
remove method
The remove method deletes the specified user.
Note: In most cases it is recommended that you disable the user account rather than
delete the user. Disabling the user account allows you to keep all information related to
the user, including data changes and the user's resources, while preventing the user from
signing in to Maestro. For example:
user.setProperties({isAccountDisabled:true});
Syntax
rapidResponse.users.remove(userId);
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
User.NotFound The specified user does not exist.
Example
This example deletes the user specified by a script argument.
profilePicture String A base64-encoded String that represents an image file. This string is used to
set the user's profile picture.
forwardToEmail Boolean If true, messages sent to the user are also sent to their email address.
userLicenseType String The user's type. This can be one of the following values:
l Full
l Light
l Report
l Alert
l System
visibilityLevel String The user's visibility level, which determines which users can see information
about each other. The following values are valid:
l Full (corresponds to visibility level of All)
l Limited
l None
Method Description
setProperties(profile) Sets the specified user properties.
setProperties method
The setProperties method modifies the user's properties to match the provided settings.
Syntax
user.setProperties(profile)
Returns
Type Description
Object A new UserCollectionObject object that reflects the property changes.
Exceptions
The setProperties method can throw the following exceptions.
Exception Description
ArgumentError A blank string, undefined value, or null value was specified for the property of the profile
object.
rapidResponse.users["testuser"]
.setProperties({contactInfo: {phone: "6131234567"}});
This example modifies a user to allow it to sign in only from a single sign-in infrastructure.
This example takes an image file and user from script arguments and sets the user's profile
picture to the image.
Note: This method cannot assign a password to users assigned an Alert license type
because alert users do not have passwords specified in Maestro.
setPassword method
The setPassword method sets the password of an existing user.
Syntax
user.setPassword(password)
Returns
A Boolean value indicating whether the password was changed.
Exception Description
ArgumentError A blank string, undefined value, or null value was specified for the
password parameter.
User.SSOOnlyRestriction The user can sign in only from a single sign-in infrastructure, and cannot
have its password specified in Maestro.
PasswordPolicy.TooShort If password policies are used, the specified password does not meet the
length requirement of the password policy
PasswordPolicy.NotComplexEnough If password policies are used, the specified password does not meet the
complexity requirement of the password policy.
PasswordPolicy.UsedPreviously If password policies are used, the specified password has already been
used .
PasswordPolicy.SameAsOldPassword If password policies are used, the specified password is identical to the
current password .
Example
This example changes the password of user "jsmith".
rapidResponse.users["jsmith"].setPassword("newpassword123");
LoggedOnUser object
The LoggedOnUser object represents the user running the script. The LoggedOnUser object
contains the following properties.
profilePicture String A base64-encoded String that represents an image file. This string is
used to set the user's profile picture.
openResourceOnSignIn Object The resource that is opened when the user signs in.
Method Description
hasPermission(permission) Determines whether the user has the specified permission.
Permissions object
The Permissions object defines the permissions the LoggedOnUser has for performing
operations. The Permissions object has the following properties.
sendLinks Boolean Whether the LoggedOnUser has permission to create and send dashboard links
to other users.
hasPermission method
Determines if the user running the script has the specified permission.
Syntax
rapidResponse.loggedOnUser.hasPermission(permissionId)
Type Description
Boolean l true if the user or group has the permission
l false if the user or group does not have the
permission
Exceptions
Exception Description
Permission.NotFound The permission ID does not exist.
Example
This example determines if the user running the script has permission to author workbooks.
rapidResponse.loggedOnUser.hasPermission("AuthorWorkbooks");
setProperties method
Specifies user properties for the user running the script.
Syntax
rapidResponse.loggedOnUser.setProperties(properties);
where
Returns
No return value.
Exceptions
The setProperties method can throw the following exception.
Exception Description
ArgumentError A blank or null value was passed for a parameter.
rapidResponse.loggedOnUser.setProperties({forwardToEmail:true});
This example takes an image file the from script arguments and sets the user's profile picture to
the image.
The Group object defines a group, and all groups are contained in the groups collection. The
Group object contains the following properties.
GroupProfile object
The GroupProfile object contains all properties of a group, including its members, responsibility,
and permissions. The GroupProfile object contains the following properties.
notifyNewMembers Boolean If true, members are sent a notification message when they join
the group.
notificationBody String The main text of the notification message sent to new members.
maxScenarios Number The number of scenarios general users in the group are allowed
to own.
This does not apply to administrators in the group, who always
use the system default scenario limit.
groups collection
The groups collection contains all groups defined in Maestro.
The groups collection contains the following methods.
Method Description
create (name, profile) Creates a user group with a specific name and group profile.
create method
The create method creates a user group and adds it to the collection.
Syntax
rapidResponse.groups.create(name,[profile]);
profile Object Optionally specifies the properties of the created group, specified using a
GroupProfile object.
Returns
Type Description
Object A GroupCollectionObject object.
Exception Description
Group.NonUniqueName A group with the specified ID already exists.
Example
This example creates a basic user group called BuyersNA.
rapidResponse.groups.create("BuyersNA");
remove method
The remove method deletes the specified user group.
Syntax
rapidResponse.groups.remove(name);
Returns
No return value.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Group.NotFound The specified user group could not be found.
Example
This example deletes the user group specified by a script argument.
GroupCollectionObject object
The GroupCollectionObject object defines the properties of a group.
members Object A collection of users and user groups that belong to the group.
The members property refers to a collection of user and group objects. Each object has the
following properties.
Method Description
setProperties(profile) Sets the specified user group properties.
remove(principalId, principal) Removes the user or group from the user group.
setProperties method
The setProperties method modifies the group's properties to match the settings provided by a
GroupProfile object.
Returns
Type Description
Object A new GroupCollectionObject object that reflects the property changes.
Exceptions
The setProperties method can throw the following exceptions.
Exception Description
Group.NoPermission You do not have permission to modify user groups.
Example
This example adds the description "Buyers North America" to the BuyersNA user group and sets
the scenario limit for this group to 30.
rapidResponse.groups["BuyersNA"].setProperties({description:"Buyers North
America", maxScenarios:"30"});
add method
Adds the user or group to the user group.
Syntax
group.add(principalId);
group.add(principal);
principal object The user object or group object to be added to the user group.
Returns
No return value.
Exceptions
The add method can throw the following exceptions.
Exception Description
Principal.NotFound The user or group does not exist.
Example
This example adds the user with the user ID "jsmith" to the Buyers group.
rapidResponse.groups["Buyers"].add("jsmith");
remove method
Removes the user or group from the user group.
Syntax
group.remove(principalId);
group.remove(principal);
principal object The user object or group object to be removed from the
user group.
Exceptions
The remove method can throw the following exceptions.
Exception Description
Principal.NotFound The user or group does not exist.
Example
This example removes the user with the user ID "jsmith" from the Buyers user group.
rapidResponse.groups["Buyers"].remove("jsmith");
The server property provides methods that execute some Maestro server commands. These
commands are also used in Maestro scheduled system tasks. You must be a system administrator
to create or run scripts that call these methods. In addition, these methods are available only if
your company uses On-Premises Maestro.
The server commands executed by these methods do not send notification messages to your
Message Center. For example, a data update executed through a scheduled system task sends all
data administrators a summary of the records inserted, modified, or deleted by the data update,
but a data update executed through a script does not. Instead, you can define how you want to
be notified of any server operation you execute in your scripts, or execute several server
commands in a script and send a notification that addresses all operations performed.
Regardless of how you define notifications, server operations are recorded in the Administration
Log workbook. For information about the Maestro Server commands and logging, see the
Maestro Administration Guide.
Method Description
executeCreateDataPackage Creates a data package, using the optional values supplied for the
(packageOptions) packageOptions parameter to determine how the package is created.
executeDataIntegrityCheck Performs a data integrity check operation, using the optional values
(checkOptions) supplied for the checkOptions parameter to determine which scenarios are
checked.
executeCancelDataUpdate() For a data update that fails a tolerance test, cancels the data update.
executeCommitDataUpdate() For a data update that fails a tolerance test, commits the data update.
executeExtractData(scenario, folder, Performs a generate extract operation, which extracts the specified table
tables) data to the specified location.
executeExtractNetChangeData Performs a generate net change extract operation, which extracts the data
(scenario, baselineScenario, folder, changes from the specified tables to the specified location
tables)
executeCreateDataPackage method
The executeCreateDataPackage method creates a backup data package, which contains copies
of your workbooks, data, and log files. You can use this package to back up your resources, or to
provide information for diagnosing server issues.
Syntax
serverObject.executeCreateDataPackage(packageOptions);
Returns
No return value.
Exceptions
The executeCreateDataPackage method can throw the following exception.
Exception Description
Server.CreateDataPackage.NoPermission You do not have permission to run this command.
Example
rapidResponse.server.executeCreateDataPackage(
{
path: "C:\\package_directory"
}
);
executeDataExpiry method
The executeDataExpiry method performs a data expiry command, which deletes system data that
is older than the defined expiry rules.
Syntax
serverObject.executeDataExpiry();
Returns
No return value.
Exception Description
Server.DataExpiry.NoPermission You do not have permission to run this command.
Example
rapidResponse.server.executeDataExpiry();
executeDataIntegrityCheck method
The executeDataIntegrityCheck method performs a data integrity check, which determines
whether data in scenarios contains errors.
Syntax
serverObject.executeDataIntegrityCheck(checkOptions);
Returns
No return value.
Exceptions
The executeDataIntegrityCheck method can throw the following exception.
Exception Description
Server.DataIntegrityCheck.NoPermission You do not have permission to run this command.
rapidResponse.server.executeDataIntegrityCheck();
executeDataSynchronize method
This method performs a data update using every data extract folder in a specified named extract
location. The folders included in the data synchronize operation must contain timestamps. In a
standard data update, the parent folder would be removed as part of the update process. The
DataSynchronize process retains the parent folder, and removes only the folders that are used in
the data update, so you do not have to re-create the parent folder as part of your data extraction
process. For more information about data updates, see "executeDataUpdate method" on page
529.
This method is typically used to perform data updates that bring changes from one Maestro
instance server into another, and can be used in any case where you have multiple named extract
folders and want to bring all of them in to Maestro without deleting the parent folder. For more
information, see the Maestro Data Integration Guide.
A data synchronize operation cannot run on a folder that is already being processed by another
data synchronize operation. You must wait until the process is complete before running the next
data synchronize operation.
Syntax
rapidResponse.server.executeDataSynchronize({options});
Parameter Type Description
options Object Optionally, the options passed to the DataSynchronize command. This can contain
the following options, which are both specified as String values:
l "NamedExtractSet": Mandatory option that specifies the name of the
folder that contains the data extract folders to be brought in to Maestro
through data updates. This folder is specified relative to the
NamedExtractSets folder under the Maestro folder.
l "Scenario": Optionally, the name of the scenario to update data in. If not
specified, the root scenario is used. Only the name of the scenario should
be provided.
Returns
No return value.
Exception Description
ArgumentError An invalid parameter or null value was provided as a parameter.
Examples
This example performs a data update using data from all folders under the NamedExtractSets
folder.
rapidResponse.server.executeDataSynchronize({"NamedExtractSet":"."});
This example performs a data update using data from folders under a folder named Demands,
and updates data in the Pending Update scenario.
rapidResponse.server.executeDataSynchronize({"NamedExtractSet":"Demands",
"Scenario":"Pending Update"});
rapidResponse.server.executeDataSynchronize({"NamedExtractSet":"Demands"});
rapidResponse.server.executeDataSynchronize({"NamedExtractSet":"Supplies"});
executeDataUpdate method
This method performs a data update, which brings extract data into Maestro.
Returns
Log information about the data update's operations. This information is also displayed in the
Data Import and Update Log workbook. For more information, see the Maestro Administration
Guide.
Exceptions
The executeDataUpdate method can throw the following exceptions.
Exception Description
ArgumentError An invalid data update parameter or null value was provided as a
parameter.
Server.DataUpdate.ToleranceFailed The data included in the data update fails a data tolerance test.
Server.DataUpdate.NoPermission You do not have permission to perform the data update operation.
Examples
The following example performs a data update.
The following example performs a data update that only inserts records in the Transaction Data
scenario.
The following example performs a data update test in the Transaction Data scenario, which
brings in only 50 changes for each table and creates a detailed transaction log.
executeCommitDataUpdate method
For a data update that has failed a tolerance test, commits the data update. This method allows
you to commit the data and ignore the data tolerance tests. This can result in invalid data.
Syntax
rapidResponse.server.executeCommitDataUpdate();
Returns
A String value that indicates whether the operation was successful.
Exceptions
The executeCommitDataUpdate method can throw the following exceptions.
Exception Description
ArgumentError A parameter was passed to the method.
executeCancelDataUpdate method
For a data update that has failed a tolerance test, cancels the data update. This deletes the
temporary scenario that stores the data to be used in the update.
Syntax
result = rapidResponse.server.executeCancelDataUpdate();
Returns
A String value that indicates whether the operation was successful.
Exceptions
The executeCancelDataUpdate method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was specified for the name
parameter.
Examples
The following example cancels a pending data update.
executeDeleteFiles method
Deletes files and folders from a specified path, which must be accessible from Maestro.
Syntax
result = rapidResponse.server.executeDeleteFiles({path});
Returns
An object that contains the return code from the DeleteFiles command.
Exceptions
The executeDeleteFiles method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was specified for the path parameter.
Server.DeleteFiles.InvalidPath The specified path is not a valid file path, or contains unsupported
characters.
Server.DeleteFiles.BadPrefixKey The path parameter does not contain a valid file location.
Examples
This example deletes all files and folders from the Files file location.
This example deletes all .csv files in the Demands folder under the ExtractedFiles file location.
This example deletes any file that ends with 'Notes' from the Master folder under the Files file
location.
executeExtractData method
Performs an ExtractData command, which creates tab files representing the data in the Maestro
database. The data is extracted from a specific set of tables. A full extract is created using this
method, which includes all data from the tables. For more information, see the Maestro Data
Integration Guide.
You must be a Maestro system administrator to call this method.
Syntax
rapidResponse.server.executeExtractData({scenario, folder, definitionId});
folder String The file location where the extracted files are saved. This must be a file location that
has been defined in the RapidResponse Administration workbook. For more
information, see the Maestro Administration Guide.
definitionId String A String that defines the extract definition that contains set of namespaces and
tables to extract. For more information, see " Defining tables for extracting data" on
page 541.
Returns
An object that contains the following:
Property Description
GenExHistoryId The extract identifier. This is a GUID that can be used to identify the extract in other
processes.
ReturnCode Whether the extract succeeded or failed. Successful extracts return the value "Ok".
Scenario The name of the scenario the data was extracted from.
ExtractDefinition The name of the extract definition that defined the data to extract.
Exceptions
The executeExtractData method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was specified for the name
parameter.
Server.ExtractData.FolderDoesNotExist The specified folder does not exist and must be created
before the method is called.
Server.ExtractData.MissingPrefixKey The value specified for the folder parameter does not
contain a file system name in its prefix.
Server.ExtractData.InvalidPrefixKey An invalid file system record was provided for the folder
parameter.
Examples
The following example extracts data from all tables defined in the "All_Mfg" definition.
The following example extracts data from all tables defined in the "No_Historical" definition.
The following example returns the extract identifier for an extract using the All_Mfg definition.
executeExtractNetChangeData method
Performs an ExtractNetChangeData command, which creates tab files representing differences
between a scenario and its parent for a set of database tables. For more information, see the
Maestro Data Integration Guide.
This method creates .partial tab files for tables with keys, and .full tab files for tables that do not
have keys. The .partial files contain only records that are different from the specified scenario
and its parent, but .full files contain all records in the table.
You must be a Maestro system administrator to call this method.
Syntax
rapidResponse.server.executeExtractNetChangeData({scenario,
baselineScenario, folder, definitionId});
baselineScenario Object The scenario that is used to determine the changes to extract. This scenario must
be a child of the scenario specified for the scenario parameter.
folder String The file location where the extracted files are saved. This must be a file location
that has been defined in the RapidResponse Administration workbook. For more
information, see the Maestro Administration Guide.
definitionId String A String that defines the extract definition that contains set of namespaces and
tables to extract. For more information, see " Defining tables for extracting data"
on page 541.
Returns
An object that contains the following:
Property Description
GenExHistoryId The extract identifier. This is a GUID that can be used to identify the extract in other
processes.
ReturnCode Whether the extract succeeded or failed. Successful extracts return the value "Ok".
BaselineScenario The scenario used to compare current data to the previously extracted data.
ExtractDefinition The name of the extract definition that defined the data to extract.
Exceptions
The executeExtractNetChangeData method can throw the following exceptions.
Exception Description
ArgumentError A blank string or null value was specified for
the name parameter.
Examples
The following example generates a net change extract for a private scenario for only the tables
defined in the "All_Demand" definition.
The following example generates a net change extract for all tables defined in the "NoHistory"
definition.
The following example returns the extarct identifier if the extarct was successful.
executeRestart method
The executeRestart method shuts down and restarts the Maestro server.
Syntax
serverObject.executeRestart();
Returns
No return value.
Exceptions
The executeRestart method can throw the following exception.
Exception Description
Server.Restart.NoPermission You do not have permission to run this command.
Example
rapidResponse.server.executeRestart();
Expression Description
"Mfg::*" Extracts all tables from the Mfg namespace.
"Mfg::*Demand*,User::*Demand*" Extracts data from all tables in the Mfg and User namespaces that have
'Demand' in their name.
"Mfg::*, !Mfg::Historical*" Extracts data from all tables in the Mfg namespace, except for any table
whose name begins with 'Historical'.
You can also specify filter expressions to apply to the tables present in an extract definition.
These filters limit the records included in the extract, and are used every time the extract
definition is used to extract data. Each filter expression applies to a single table, and must be a
valid filter expression that contains a comparison operator. A filter expression for a table is
associated with a specific extract definition, and is used only when that extract definition is used.
Because the filter is specified in the definition, it cannot be validated before being used. It is
recommended you develop a filter expression either in a worksheet to verify it returns the
correct results, or use it to extract data on a test system. The filter expression cannot contain
square brackets ([]).
When you create an extract definition, you can use it in a script by passing its name as a
parameter to the executeExtractData or executeExtractNetChangeData method. For more
information, see "executeExtractData method" on page 534 and "executeExtractNetChangeData
method" on page 537.
1. In the Administration pane, under System Settings, click Scheduled System Tasks.
2. Click the Extract Definitions worksheet tab.
3. On the Edit menu, click Insert Record.
4. For the new record, specify the following:
l Extract ID: The name of the definition. This name will be used in method calls.
l Table Selection String: The expression that defines the tables to be extracted.
l Description: Information about the definition.
1. In the Administration pane, under System Settings, click Scheduled System Tasks.
2. Click the Extract Configuration worksheet tab.
3. On the Edit menu, click Insert Record.
4. For the new record, specify the following:
l Extract ID: The definition this filter is used by.
l Table: The namespace and table the filter applies to.
l Filter Expression: The filter expression to apply to the specified table. For more
information, see the Maestro Resource Authoring Guide (Java client)
5. If you are applying filters to multiple tables, click Save, and then repeat step 4 for each
table you want to apply a filter to. Otherwise, click Save and Close.
Note: If your extract definition includes tables from only one namespace, you can
specify only the table name for the Table value. However, it is recommended you include
the namespace to ensure the correct table is filtered if the extract definition is modified.
rapidResponse 100
Resource 106
HelpInformation 107
Resource collection 107
accessControlList collection 119
Principal 123
PermissionCollection 123
Permission 127
Script 130
scripts collection 130
Scenario 140
Perspective 142
ActivityLog 142
scenarios collection 143
Options 149
Options 164
cdcInstances collection 172
CDCInstance 173
Workbook 176
WorkbookInitialization 177
WorkbookHierarchyInitialization 178
Path 179
Variable 179
WorkbookPreferences 179
workbooks collection 179
dependencies collection 195
WorkbookDependency 195
.ipk Alert
See "integration package." A type of resource used to monitor data
and send notification messages when the
.kpk data meets a specified condition.
See "application package."
Allocation (demand)
.rpk A dependent demand created to provide
See "resource package." some supply to satisfy an independent
demand.
.spk
See "user group package." Allocation (supply)
Supply used to satisfy a demand. Portions
A of one supply order can be allocated to
several demand orders. Supply can also
Accepted forecast be allocated from one site to satisfy
A forecast created by your company demands at another site.
indicating the quantities you are willing
to commit to a customer. Allotment
See Allocation (supply)
Active forecast
Forecast records that can be consumed, Application package
and that contribute to other demands. A file that is used to migrate any
combination of user groups, resources,
Activity (workflow) data model changes, and other
Represents the work actions performed in integration settings between servers.
a workflow, either individual tasks or
tasks grouped into sub-processes. Approved Actions (scenario)
Represents the most recent data in
Activity Log Maestro. This scenario is typically used as
Records the actions performed on a the basis for simulation scenarios.
scenario, including what was done, who
Commit Constraint
Merge a scenario with its parent. Data A limit on production, measured as a
differences in the child scenario are number of units per a period of time.
reflected in the parent scenario’s data. Constraints can refer to the maximum
daily output of a machine or a limit on
Comparison scenario weekly available supply.
In a worksheet that displays data from
multiple scenarios, this scenario is Contract manufacturer
compared to the user’s selected scenario. A company that manufactures products,
sub-assemblies, or components
Composite worksheet according to designs and specifications
A worksheet that displays data from one provided by a brand owner.
or more other worksheets. These
worksheets typically display data from a Controller worksheet
wide variety of tables. A worksheet that provides a switchable
view of multiple worksheets within a
Concatenation single workspace.
Data operation that combines two or
more String values into one. See also Cost of goods sold (planned)
String. The total cost of each part your company
sells. Includes material, labor, and
Conditional formatting overhead costs.
Changes the appearance of a column
depending on the data values in the Cost of goods sold (standard)
column. The cost of each part your company sells,
as specified in your enterprise data
Conditionally editable sources. This is also called the standard
A worksheet column that can be used to cost or standard unit cost.
modify data only when a specific
condition is met. Critical path
The longest path from top to bottom of a
BOM. Represents the parts leading from
the lowest level of the BOM to the root
Event phase
A period during which the demand or
unit price for a product is expected to
Margin MRPDate
The profit made on each part sold. See Planning date.
P
Personal resource tag
A resource tag that users can apply to
Parameter (macro) group resources and quickly locate them.
Information required by some macros. Personal resource tags are only visible to
These values are used in the macro’s the user who created them.
calculation, and are typically obtained
from fields on the table the macro is Perspective
running on. A set of control values applied to a
scenario. These are typically used to
Part sequence create a scenario with specialized
The sequence number assigned to a part. calculations, and can only be applied
when the scenario is created.
Part source
A delivery method for supply of a part. Planning date
Part sources are typically defined by the The first date that action can be taken.
method of transportation, the routing,
and the cost of transporting the parts. PLM repository
Product Lifecycle Management
Part sources (data errors) repository. Contains information about
Errors with the sources associated with your parts and how they are constructed.
your company’s parts, including parts Engineering changes are made by first
with no active source or inconsistent lead modifying the part in the PLM repository,
times, cost information, and units of and then bringing the changes into
measure. See Part source. Maestro.
Process instance Q
User-facing occurrence of an actionable
company process. Quantity variable
A workbook variable that contains a
Production cycle Quantity value. The value is inserted into
A series of tasks related to the expressions that use the variable.
transformation of raw materials into
finished goods. Query expression
See Expression.
Production group
Parts with an assigned priority organized
by and associated with a specific site. R
Target Transaction
Goal set for a metric. Each metric can Any change made to data.
have a different target, and a scenario’s
performance is judged by how close its Transfer demand
metric results match the targets. Demand on a supply site. This demand is
satisfied by transferring supply to a
Task flow demand site. Transfer demand is created
A type of resource that contains when a direct demand on a demand site
procedures you can follow to perform a is satisfied using supply from the supply
task. Each step of the task flow typically site.
provides the resources required to
complete the step. Treemap
An interactive visualization of a large data
Text variable set that helps you recognize patterns and
A workbook variable that contains a text identify outliers and problem areas. Data
string. The text is inserted into is grouped into categories and
expressions that use the variable. subcategories, represented by rectangles.
Time-based scorecard U
A scorecard that shows scores for metrics
over time. Undefined (date)
A date constant that does not refer to a
Timeline visualization valid date. Typically used when a date is
Enables users to view data not important, such as a due date for an
chronologically on a time axis to identify unscheduled order.
patterns, spot outliers, and analyze how
key metrics change over time. Unlicensed table
A database table that your company is
Today (date) not authorized to use.
A date constant that references the
current date. Update (data)
Data from your enterprise data sources is
Today (scenario) brought in to Maestro, modifying the
Represents the data in Maestro as it was data in the Enterprise Data scenario
immediately following the most recent where applicable. Data updates are
data update. This scenario is typically typically performed daily.
Workbook controls
W Allow workbook users to specify filtering
options for the workbook they are using.
Waterfall report
Worksheet that displays how historical The selections made in these controls
data changes over time. limit the data displayed in the workbook.
Workflow
A collection of related processes and
tasks organized in an automated
sequence to achieve a specific business
outcome.
Worksheet
Displays data from the Maestro database.
Worksheet-based alert
Monitors data in a worksheet, and alerts
when the data in the worksheet meets a
specified condition.
Worksheet filtering
Limits the records displayed in a
worksheet to only those matching a
query expression.
Worksheet Identifier
Internal name for the worksheet. Each
worksheet in a workbook must have a
unique identifier.