Creating a Migration Robot in Kapow Design Studio – Part 4 of 5


Loop Execution

There are two types of loops that I need this robot to execute. The first loop requires clicking on the hotspot for each record displayed in the view. The second loop requires clicking on the [Next] hotspot to open the next list of records in the web browser.

clip_image001

Looping through the records listed in the view took a while for me to figure out. The problem was that there were so many similar tags for the robot to choose from. I had to make sure that the action step was properly defined. I ended up asking for help from Kapow Support.

I created a new tag after the snippet that I just created. I used the “For Each Tag Path” action and set the tag path to “tr”. Of course, “tr” refers to a table row tag in a table. I set the First Tag Number to “1” to skip the first “tr” because it did not contain a hotspot that opened a record.

clip_image002

Now click on the “Tag Finders” tab. I set the “Find Where” value to “In Current Tag” and set the “In this Tag” value to “Data Body”. You may recall that step 6 in the “Move to Starting Tag” had the “Name” property set to “Data Body”.

clip_image004

The “Tag Path” property is set to “*”.

clip_image005

The second loop actually appears as a branch prior to the “For Each Tag Path” step that I just created. I right-click on the “Move to Starting Tag” step and select [Add Branch].

clip_image006

I click on the “x” at the end of the new branch.

clip_image007

I scroll down the web browser window until I see the [Next] hotspot.

clip_image008

I right-click on the [Next] hotspot and select [Click] in the drop-down menu.

clip_image009

The new Click step should appear as below. Note how the current tags that were defined earlier continue be used.

Step

Tag Finders

Action

Click

clip_image011

clip_image013

There is one other thing about the “Click Next” step. I modified the “Error Handling” tab to “Ignore and Continue” when there is an error. So the robot should end when there is no [Next] hotspot to click.

clip_image014

Now insert the snippet that was created earlier. We need to get back to the same starting tag after the new web page opens.

Right-click on the “Click URL” step and select [Insert Snippet Step After].

clip_image015

The step appears as “Unnamed”.

clip_image016

Click on the “Select a Snippet” button on the Snippet tab and select the “Moving_to_Starting_Tag” option. The step appears correctly with the snippet name.

clip_image017

I click on the arrow at the end of the new branch. The arrow connects the “Move to Starting Tag” step and the “x”.

clip_image018

I click on the endpoint of the arrow and drag and drop it onto the circle that appears in front of the “For Each Tag Path” step.

clip_image019

This completes the second loop. The “Click Next” step will run every time that the “For Each Tag Path” loop runs out of hotspots to click.

Click URL Step

Next I created the “Click URL” step. I selected the first hotspot that opened a record in the web browser window.

clip_image020

I right-clicked on the hotspot and selected “Click” in the drop-down list.

clip_image021

This creates a Click action step. The Tag Finders tab appears as below.

clip_image022

Note that the “In this Tag” property value is “1”. This is the current highlighted tag.

clip_image023

The “Tag Path” value is “.*.font.a.”. You can see that the tag path points to the correct hotspot in the selected <tr>.

clip_image024

Extract Field Values

Now we need to extract the field values from the source document. The “Click URL” step opened a web page with Notes document details.

clip_image025

I want to capture these values and store them in a local database. I start by clicking on the text in the blue banner at the top. The text is highlighted in green.

clip_image026

The same HTML is also highlighted in the HTML View window.

clip_image027

Right-click on the selected text and click on Extract \ Extract Text \ Post.Title.

clip_image029

The extraction step is created with everything that you need in place!

Step

Tag Finders

Action

Extract Title

clip_image031

clip_image033

Repeat this for the following fields: Title, Description, Submitted By, Category, Audience, Product, Release, Platform, Submission Date, File Size, File Size Type, and URL. You should end up with a group of steps that appears as below.

clip_image035

Note the following:

· I grouped my steps together in a group named “Extract Field Values”.

· I changed the Error Handling for the “Extract Submission Date” and “Extract File Size” steps to log an error and then “Ignore and Continue”.

clip_image036

· The File Size Type value is likely always going to be “bytes”.

· The URL value is the “Click here to download” URL

clip_image037

Assign Unique ID

Right-click on the new group of tasks that you created and click on [Insert Step After].

clip_image038

Set the name of the new step to “Assign UniqueID”. No change to Tag Finders. Set the action to “Assign Variable”. Set the value to guid() and assign to Post.UniqueID. This will set a unique guid value to the UniqueID column in the row of data.

Step

Tag Finders

Action

Assign Unique ID

clip_image040

clip_image042

Extract the File Attachment

Right-click on the “Click here to download” hotspot.

clip_image043

Click on the Click option in the drop-down list.

clip_image044

A new step is created. Edit the Step Name to “Click Here to Download” on the Basic tab. Editing the remaining properties should not be required; but the values are provided below for your benefit.

Step

Tag Finders

Action

Click Here

clip_image046

clip_image048

Click on the “x” in the robot view window.

clip_image049

The contents of the web page at the URL should load in the Windows view for you to see.

clip_image051

Scroll down to the bottom of the window.

clip_image052

Right-click on the “I have read and accept the terms and conditions” text and click on the Extract \ Extract URL \ Post.URLFileAttachment options.

clip_image053

A new step is created. Rename the step to “Extract File URL”.

Right-click on the “Extract File URL” step and click on the “Insert Step After” option.

Set the name of the new step to “Assign Variable”. No change to Tag Finders. Set the action to “Assign Variable”. Set the value to:

substring(Post.URLFileAttachment, indexOf(Post.URLFileAttachment, "$FILE/")+6, length(Post.URLFileAttachment)-12)

and assign to Post.FileName. This will get the filename value from the URL and save it to a column value. The filename will later be used to find the file and load it to the target list on SharePoint.

Step

Tag Finders

Action

Assign Variable

clip_image040[1]

clip_image055

Right-click on the “I have read and accept the terms and conditions” text and click on the Click option in the drop-down list.

clip_image044[1]

A new step is created. Edit the Step Name to “Extract File Attachment” on the Basic tab. No change to Tag Finders. Set the action to “Extract Target”. Set the values on the Action tab to be the same as those displayed in the table below.

This will extract the file and save it locally in the C:\Temp folder. The file will later be loaded to the target list on SharePoint.

Step

Tag Finders

Action

Extract File Attach-ment

clip_image057

clip_image059

Unfortunately, I did run into problems with finding the right tag to extract the files because the HTML is never quite the same from one web page to the next. So I had to set a series of “Set Current Tag” steps to get to the correct starting tag.

clip_image060

The details of each step are displayed below.

Step

Tag Finders

Action

Set Current Tag

clip_image062

clip_image064

Set Current Tag

clip_image066

clip_image068

Set Current Tag

clip_image070

clip_image072

Set Current Tag

clip_image074

clip_image076

Then I had to set a loop to test and get to the correct table row. I am sure that there is a better way; but this will do for now. Basically, I created steps that go row by row looking for the URL to click on. The robot skips to the next row if there is an error. I hard-coded the table row reference.

clip_image077

The details of the first two steps are displayed below. The process repeats itself for the remaining steps. The Tag Path changes to refer to the next table row # (e.g. tr(4)). The name of the current tag includes the row # (e.g. DownloadColumn4).

Step

Tag Finders

Action

Set Current Tag Row 4

clip_image079

clip_image081

Click here to download

clip_image083

clip_image085

The Error Handling tag is the same for every step. Basically, ignore the error and continue.

clip_image086

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s