Let's handle any exceptions within the Catch block:
- In the Catch block, we will handle system exceptions. So, let's choose Exception as System.Exception. Click on Add Activity in the Finally part and add a Log Message of Log Level set to Error with a message stating "Not able to Extract Customer list. Due to this Error: "+exception.Message.
- If there is an exception while we extract the customer list from CRM, then Automation won't be able to proceed. Let's add a Terminate Workflow activity to handle this. Within the properties for the Terminate activity, set Exception to exception (start typing and the list should pop up) and add "Cannot Extract Customer list from CRM, so terminating the Automation." as a reason, as shown in the following screenshot:
- Now, we have completed the first part of extracting the customer list from CRM. To test this Sequence, let's add a Message box activity with the message dtCompanyList.Rows.Count at the end of the Try block, after the Extract Structure Data activity.
- Let's run and test the Automation we have so far. Ensure that Apptivo is open in Chrome. Go ahead and click the Run button on the Studio ribbon. If the message box returns your number of customers (3, in our case), then we have successfully completed this part of the main workflow.
- Please ensure you remove the message box after the unit test has completed.
Next, we will use the customer's names to look up their information from the Crunchbase website.