Automatic DocuSign Workflows
The native DocuSign integration with Anaplan makes it simple to share information between Anaplan and Docusign, but the process to issue envelopes or track changes back in Anaplan can sometimes be quite manual and time-consuming as envelope counts begin to increase.
This article will walk through a script to automate this process. This solution requires Python (written for 3.8) and ChromeDriver, a tool for automating web UI interfaces. Although written in Python, this script is quite simple to maintain, only requiring that you update the Anaplan and DocuSign passwords when they change. All of the user-relevant variables are found at the top of the script:
Here you can see the following variables:
- chromedriver_location: The path where you downloaded Chromedriver.
- username: Your Anaplan username.
- password: Your Anaplan password.
- docusign_username: The Docusign account that has access to the envelopes you're sending.
- docusign_password: Your Docusign password.
- workspace: The name of the workspace of your Anaplan model.
- model: The name of your Anaplan model that contains your Docusign details.
- search_terms: The names of the Docusign workflows you wish to update.
- date_range: Here you can define how far back the script will look when updating workflow status. The initial value is for 31 days.
The first step for the script is to open an incognito instance of Chrome to avoid any caching issues, and then log into Anaplan. Then, open the DocuSign add-on.
Occasionally, the browser will redirect to the DocuSign login page. After initially opening the add-on page, the script waits for a few seconds, then detects whether the DocuSign login is detected. If not, it enters the workspace and model details you provided and brings you to the landing page for the add-on.
Next, the script opens the workflows pane, clicks into the workflows you defined in search_terms, and sends updates, if any exist. This will check whether there are any unsent messages for the defined workflows and send them out.
Here, you'll see some long sleep times where we're telling the script to wait for some number of seconds before proceeding. This is to ensure that the page has fully rendered and all buttons are clickable. Since this is an unattended script, I decided to invest time in finding the optimal time to wait in order to get execution time as fast as possible. I also wanted to have a sufficient window to handle unexpected slowness in the network.
Finally, after all workflows are updated, the script moves onto sending updates back to Anaplan. It searches for the workflow name, then gets the total number of items for that workflow. Here it loops, clicking into each item for your search term, and sending an update back to Anaplan.
This is also where the script reads the sent date of each item it finds, and if that date is within the window you defined in User Variables, it clicks into that item to send updates back to Anaplan. This means the script isn't spending time trying to update items that are weeks, months, or years old.
Finally, once all items in all search terms are updated the script reports back how many items it updated to Anaplan.