Create Custom Cloud Loaders
Thorough JavaScript programming knowledge and experience are required to build a Custom Cloud Loader. You should not begin creating a Custom Cloud Loader if you do not have access to an experienced JavaScript programmer. You must also be assigned the Integration Developer permission in Administration > Permission Sets before attempting to create a Custom Cloud Loader.
Custom Cloud Loaders let you export
Adaptive Planning
plan data directly to third-party cloud systems.Watch the video:
3m 16sBasic Steps
- Enter data source settings.
- Define parameters.
- Write JavaScript using the CCDS APIs in the ai Namespace.
- Define business rules.
- Run or schedule the loader.
Prerequisites
Prerequisites
- Verify that you have the Integration Developer permission.
- Verify thatAdaptive Planningplan data you want to export already exists in a staging table.
- Create an OAuth credential for your external system, or obtain credentials you can explicitly include in your JavaScript.
- Know what parameters you need to pass to your external system, and what defaults the external system expects.
- Understand how to write to the external system's endpoint.
Navigation
From the nav menu, go to Enter Data Source Settings
The Data Source Settings let you choose the source table you want to use from your instance's staging data, determine what credentials to use, and the level of log detail to record during a loader run.
Create a new Custom Cloud Loader
- Access the Data Designer by going toIntegration > Design Integrations.
- In the Loaders folder in the Component Library selectCreate New Loader.
- SelectCustom Cloud Loaderas the loader type and enter a name.If you don't see Custom Cloud Loader as an option, it isn't enabled for this instance or you don't have the Integration Developer permission needed to access it.
- SelectCreate.
Select the Source Table, Credential, and Log Level
- Enter the Custom Cloud Loader's information:
- Source Table:Select a staging table containingAdaptive Planningplanning data you want to export.
- Require Credential:Select if the external system requires OAuth and you require a user with Integration Operator permission to select the appropriate OAuth credential.
- Credential:Select a preexisting OAuth credential.
- Log Level:Select how much detail to log when the loader runs:
- Error:Only logs errors.
- Info:Logs all basic information, such as when the data source was updated.
- Verbose:Provides very detailed information about all phases and actions. Used primarily for debugging or auditing, as it may produce more log information than practical for typical use.
- ClickSavein the actions menu.
Define Parameters
Define what parameters your javaScript requires to export
Adaptive Planning
data to your external system. Parameters can include connection URLs, user names, passwords, and dimensions from Adaptive Planning
, and other information. Paremeterized settings let you change their values at run time. Static settings persist across loader runs.- SelectDesigner Settings.
- Drag Parameterized or Static setting items from theSettings Componentpane intoDesigner Settings.
- Parameterized setting values entered here become loader defaults if you don't provide another one at loader run time.
- Static settings you enter here get used every time the loader runs and don't require input at run time.
- Boolean: A value represented as one or zero.
- Dimension: A dimension from the dimension admin withinAdaptive Planning.
- Integer: A non-negative whole number.
- Password: A password. This value cannot be viewed once it is saved.
- Period Range: A time period range from withinAdaptive Planning.
- Text: An alphanumeric value.
- Double click a parameter item to enter a name and change its value.
- Drag in as many items as you need to reference in your JavaScript.
- Save the loader.
- Use a parameter's name in your JavaScript to reference it.
Write JavaScript
- SelectScript.
- Select the preexisting template and change it or selectNew Scriptto make your own.
- Write the javaScript you want the loader to execute using the CCDS APIs in the ai Namespace.
- Verify the script includes the required:
- testConnectionfunction to create an https request to post to your external system
- exportDatafunction to export data fromAdaptive Planning. See Export Data Function (Custom Cloud Loader Only) in the Adaptive Planning Functions topic.
- Reference any parameters you created in the Designer Settings by their name.
- Save the script.
You can format and beautify a script in the editor using the keyboard shortcut
CTRL + Shift + B
. Find and replace launches with Ctrl+H
.You can separate a long script into multiple files for easier maintenance.
Example: You could contain all of your
testConnection
logic in one script called testconnectionscript
. A second script, called exportdatascript
, could contain all of the exportData
logic. When the same function is declared in multiple scripts, the one from the most recently added script is used.
Use OAuth in Custom Cloud Loader Scripts
When you select Require Credential for a Custom Cloud Loader, your script must contain
ai.https.authorizedRequest.
See Authenticate with OAuth for how to create an OAuth Credential.
Those who run a Custom Cloud Loader referencing a Credential should:
- SelectRequest Authorizationbefore running the loader.
- Provide any additional authorization details, such as scope, needed for the external system endpoint.
- SelectTest Connectionto verify the OAuth credentials passed successfully to the endpoint.
- Note the authorization date and user ID in the Authorization Status. Authorization expiration dates vary from one external system to another. Select Reset Authorization in the Actions pane to reauthorize when needed.
Define Business Rules
You can use Business Rules to create SQL expressions that limit the staging data that exports to the external system. Only records that meet your filter criteria will load.
The Business Rules tab contains a text area for entering SQL.
- Select theBusiness Rulestab.
- SelectEdit.
- Enter an SQL expression. You can click an item in Available Columns to bring that column into the SQL expression instead of typing it.
- SelectApplyto check your syntax. Errors turn the border around the expression red. Hover the expression to see syntax error information.
- Correct any errors in your syntax and selectApply. Only staging rows that match the SQL expression will load.
Include the Custom Cloud Loader in an Integration Task
Custom cloud loaders must be run as integration tasks. Any can contain one or more loaders. A task can also contain other integration tasks and loaders. See Create Integration Tasks.
Best Practice: Have separate integration task for each loader.
If a task contains multiple loaders, then parameters from each loader are presented when the task is run. If there is a common/shared parameter used in the loader(s) within a task, then the task only prompts for the parameter once. You can choose to override parameter prompts.
For schedules runs of the task, the default values of the parameters stored when the loaders were created are used.
Sample CCL Script
Use the example below to connect to your AWS S3 instance for exporting and viewing your spreadsheet data. You will need the bucket name, key, access key, secret key and region values. For more information and example codes, see ai.awss3.
- Set up a spreadsheet data source.
- Create a new Custom Cloud Loader in theLoaderspane.
- Navigate to theData Source Settingstab and select your spreadsheet Data Source in theSource Tablefield.
- Copy the below sample script in theScriptstab.// Manually invoke this method via 'Test connection' function testConnection(context) { return true; } // Manually invoke this method via 'Run manually' function exportData(context) { //"xxx" is the name of your Amazon S3 bucket. var bucketName = 'xxx'; //Name of the sample CSV file to which data from your spreadsheet data source is exported var key = 'exampleTest.csv'; //"xxxx" is the access key for your AWS S3 bucket. var awsAccessKey = 'xxxx'; //"xxxx" is the secret key of your AWS S3 bucket. var awsSecretKey = 'xxxx'; var region = 'us-west-1'; // Step 1: Get the data var reader = context.createTableReader(); // Step 2: Process and export the data var result = "Column,Heading,Names\n"; var row = null; while ((row = reader.readRow()) !== null) { // remove meta columns we don't need row.length = row.length - 2; result += row.join() + '\n'; } ai.awss3.putFile(bucketName, key, result, region, awsAccessKey, awsSecretKey); }
- SelectSavein theActionspane.
- To execute the script, selectRun Manuallyin theActionspane.