Creating a Scripted Storyboard
The creation of a Scripted Storyboard is as simple as the creation of a normal Storyboard. Just go to the home page and create a new Storyboard. Instead of adding a New Storyboard, add a new Scripted Storyboard. Alternatively, you can copy a normal Storyboard into a Scripted Storyboard. All content of the Storyboard will be automatically inserted as the starting script for the Scripted Storyboard.
Read more in the Create Scripted Storyboard article.
Syntax and Examples
We use an industry standard scripting language for scripting a Storyboard.This makes it extremely flexible, but it also requires a bit of explanation if you want to use the advanced features. In this document we will start with very simple (Fixed) examples and slowly extend the explanation to the more advanced and more dynamic Scripted Storyboards.
Let’s first define an example structure that allows us to document these Scripts.
Entity Structure (between brackets we show the labels of the entities):
Global (GLO)
- Europe (EUR)
- Netherlands (NE)
- United Kingdom (UK)
- Europe HQ (HQ)
- Americas (AM)
- Canada (CA)
- North America (US)
- Americas Administration (AA)
- Elimination (EL)
- Europe (EUR)
We also introduce a Product Structure:
Total (TOTPROD)
- Shoes (shoes)
- Baby Shoes (babys)
- Adult shoes (adults)
- Other (Shoes_other)
- Jackets
- Baby jackets (babyj)
- Adult jackets (adultj)
- Other jackets (jackets_other)
- No Product (NoProduct)
- [None] ([None])
- Shoes (shoes)
Let’s assume we have three reports:
Profit and Loss
Balance Sheet
Sales
Example 1 - Profit and Loss for three different entities
Now lets’ say we want to create a first Storyboard, which is the Profit and Loss of European entities (Netherlands, United Kingdom and Europe HQ):
A simple (Fixed) script would look like this:
SWITCH [Entity] "NE" Run "Profit and Loss" SWITCH [Entity] "UK" Run "Profit and Loss" SWITCH [Entity] "HQ" Run "Profit and Loss"
Example 2 - Use customized report titles
We can also include the names in the Storyboard titles if we do this:
SWITCH [Entity] "NE" Run "Profit and Loss" as "Profit and Loss for [Entity]" SWITCH [Entity] "UK" Run "Profit and Loss" as "Profit and Loss for [Entity]"
Example 3 - Use a for loop and member array
We could also use an alternative statement for this, which is better if the list of entities gets larger:
EuropeEntities = Array("NE","UK","HQ") FOR ENT1 in EuropeEntities SWITCH [Entity] ENT1 Run "Profit and Loss" as "Profit and Loss for [Entity]" END
Example 4 - Use a for loop based on children
The best option is when we can make the script dynamic, by using a loop:
FOR ENT1 in @Children([Entity], "Europe") SWITCH [Entity] ENT1 Run "Profit and Loss" as "Profit and Loss for [Entity]" END
Example 5 - Add an exception
To add a little bit more complexity (and reality) into the picture, let’s say we decide to have the sales of all of the Europe entities, but not the overhead company (in this case the HQ) because they have no sales. Such a loop with exceptions will look like this:
FOR ENT1 in @Descendants ([Entity], "Europe") IF (ENT1 <> "HQ") SWITCH [Entity] ENT1 Run "Sales" as "Sales for [Entity]" END END
Example 6 - Run multiple reports using a for loop and exceptions
Now let’s go one step further and expand from Europe into the rest of the world. We will now write a script that puts the Profit and Loss, Balance Sheet and Sales reports into a Storyboard, but excludes the Sales reports for the overhead companies:
FOR ENT1 in @Descendants ([Entity], "Global") SWITCH [Entity] ENT1 Run "Profit and Loss" as "Profit and Loss for [Entity]" Run "Balance Sheet" as "Balance Sheet for [Entity]" IF (ENT1 <> "HQ" AND ENT1 <> "AA") Run "Sales" as "Sales for [Entity]" END END
Example 7 - Nested for loops
Last but not least we are going to combine things for the entity and the product dimensions: we will script a Storyboard with Profit and Loss and Balance Sheet reports for all entities and with the Sales report by product (but not for No Product and [None]) for all entities (but not for the HQ and AA overhead entities).
FOR ENT1 in @Children([Entity], "Global") SWITCH [Entity] ENT1 Run "Profit and Loss" as "Profit and Loss for [Entity]" Run "Balance Sheet" as "Balance Sheet for [Entity]" IF (ENT1 <> "HQ" AND ENT1 <> "AA") FOR PROD1 in @Descendants ([Product], "TOTPROD") SWITCH [Product] PROD1 IF (PROD1 <> "[None]" AND PROD1 <> "No Product") Run "Sales" as "Sales for [Entity] [Product]" END END END END
Example 8 - Use scripted Storyboards for multiple Source Systems
One more statement that we would like to mention is about using Storyboard across source systems. We have a USE function that determines the source, so we can specify a Profit and Loss from the finance system and a Sales report from the Sales database in the following way:
USE "Finance" SWITCH [Entity] "Global" Run "Profit and Loss" as "Profit and Loss for [Entity]" USE "Sales" SWITCH [AccountManager] "Total" Run "Sales Detail" as "Sales for the Group"
Example 9 - Use scripted Storyboards in combination with PrintMode functions:
Print orientation can be influenced by adding the following syntax to your script.
Print Mode | Portrait orientation | Landscape orientation |
---|---|---|
Fit report to width of page | * | (PrintMode = Landscape) |
Stretch report over whole page | (PrintMode = PortraitStretchPage) | (PrintMode = LandscapeStretchPage) |
Fit report on one page | (PrintMode = PortraitFitReportOnOnePage) | (PrintMode = LandscapeFitReportOnOnePage) |
Comments | ||
Include comments | * | (PrintMode = Landscape) |
Exclude comments | (PrintMode = PortraitNoComments) | (PrintMode = LandscapeNoComments) |
* Default selection, no additional script required.
USE "Finance" SWITCH [Entity] "Global" Run "Profit and Loss" as "Profit and Loss for [Entity]" (PrintMode = PortraitNoComments) USE "Sales" SWITCH [AccountManager] "Total" Run "Sales Detail" as "Sales for the Group" (PrintMode = LandscapeFitReportOnOnePage)