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 to test out the basics of the Scripting program.
Required files:
指示:
- 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:
指示:
- 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.
Script to update spreadsheets (Script-to-Update-Spreadsheets.py)
This script is a good starting point for working with the Workiva public API. For additional information, see our Workiva Developer Hub at https://developers.workiva.com/.
Required files:
指示:
- From Home, create a new script file.
- Open the Script-to-Update-Spreadsheets.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.
- Upload the requirements.txt file.
- Click Save at the top left.
- Click Run Script at the top left.
- Click +Add Variable and enter the following parameters:
- CLIENT_ID and CLIENT_SECRET: These are your OAuth2 client credentials and secret used to access the selected spreadsheet. These credentials are generated in the workspace where the spreadsheet is located.
- SPREADSHEET_ID and SHEET_ID: These are the IDs for your spreadsheet and sheet. You can find the IDs in the spreadsheet's URL (app.wdesk.com/a/{workspaceId}/spreadsheet/{spreadsheetId}/sheet/{sheetId})
- HELLO_WORLD: Enter any text you'd like. This is what the cell will display.
- Click Run Script again; the cell at the top left corner should now display the text you provided in the HELLO_WORLD parameter.
Note: This script is also covered in the Sample: Script to update spreadsheets article.
Zero suppression script (Zero-Suppression-Script.py)
This zero suppression script is one of our first accelerators -- a pre-configured package provided directly by Workiva that demonstrates the real-world capabilities of the platform. As this program and the package itself are still under development, you may notice occasional issues when using this script.
Required files:
指示:
- From Home, create a new script file.
- Open the Zero-Suppression-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.
- 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.
- Upload the requirements.txt file.
- Click Save at the top left.
You can now create an automation in the document where the empty rows are present. Your automation should use a Manual Execution trigger and a Script Execution 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.