Note: Scripting is currently only available through Customize Workiva. Learn more.
First script (first-script.py)
This simple script calculates the time value of money. Because it requires no additional libraries, it provides a good way to test out the basics of the Scripting program.
Required files:
Instructions:
- From Home, create a new script file.
- Open the first-script.py file on your machine, and copy the script code onto the blank canvas (i.e., the code-editor space for the pre-created file "__main__.py").
- Click Save at the top left.
- Click Run Script.
- Click +Add Variable and enter the following parameters:
- INVESTMENT=10000
- INTEREST_RATE=10
- COMPOUNDING_PERIOD=annual
- YEARS=1
- Click Run Script and verify the result is 11000.
Note: This script is also covered in the Intro to Workiva Scripting article.
Fibonacci (fibonacci_main.py and fibonacci.py)
Like the starter script covered above, this simple script requires no additional libraries. However, it does use script sources -- an important building block of the Scripting program.
Required files:
Instructions:
- From Home, create a new script file.
- Open the fibonacci_main.py file on your machine, and copy the script code onto the blank canvas (i.e., the code-editor space for the pre-created file "__main__.py").
- Click Save at the top left.
- Go to the Sources panel on the left side, right-click in the blank space just below the current sources, and select Upload Source Files.
- Browse your computer for the fibonacci.py file, then click Upload.
- Click Save at the top left.
- Click Run Script and verify the result is 34.
Zero suppression script (Zero-Suppression-Script.py)
This zero-suppression script demonstrates how to hide spreadsheet rows whose displayed numeric values are all zero.
Required files:
Instructions:
- From Home, create a new script.
- Open the Zero-Suppression-Script.py on your machine and paste its contents into the script’s pre-created
__main__.pysource file. - If you will run the script from an automation, replace the empty
CLIENT_IDandCLIENT_SECRETplaceholders with credentials from an API grant that has thefile:readandfile:writescopes and access to the spreadsheet. - Click Save.
- In the Sources panel, right-click below the existing sources and select Upload Source Files.
- Upload requirements.txt.
- Click Save and wait for dependency generation to complete.
You can now create an automation in the spreadsheet containing the rows you want to evaluate. Configure the automation with a Manual Execution trigger and an Execute Script action. You will need the Script ID found in the URL of your script.
When run, any empty rows should be hidden in your document.