Using an RPA to Update Illustrator Assets from Google Sheets (Part 2)

Using an RPA to Update Illustrator Assets from Google Sheets (Part 2)

Note: Due to the length of this demonstration, this article had to be split into 2 parts. This is part 2. Part 2 continues where Part 1 left off, at the step where the Illustrator process is invoked.

6. IllustratorProcess Sequence

At this point it’s time to invoke the Illustrator script and have it make the edits to the artwork assets. Inside this sequence the first item is a try-catch activity which houses the Invoke COM Method activity that actually runs the Illustrator javascript.

No alt text provided for this image
No alt text provided for this image

The COM method to use inside of Illustrator is called “DoJavaScriptFile” and it must have valid arguments including the location of the .jsx file to execute as well as an array of arguments. In this case, the array of arguments holds only a single element which is the instruction JSON string concocted by a previous Assign activity.

No alt text provided for this image

In the catch section of the try-catch activity a UiPath message box is shown which informs that a process-breaking error has occurred. For this demonstration, the workflow will not need to send a post back to Google Sheets after such an error. To control the workflow in the upcoming Flow Decision, a string variable is assigned to an empty string just after the message box is displayed. The Exception-type variable produced in the catch block of a try-catch activity has properties which can help formulate a specific error message which relates to the cause of the overall exception. Using exception.InnerException.Message it’s possible to obtain the Illustrator script’s thrown error’s detailed message. Controlled process-breaking errors can be thrown during the Illustrator script in cases where an “emergency stop” is needed.

No alt text provided for this image

To keep the variables separated, the IllustratorProcess sequence has an If-statement following the try-catch activity which assigns a variable the result of the Illustrator script run but only if it was a successful run.

No alt text provided for this image




No alt text provided for this image




Note the result string is assigned to the result variable sent from the Invoke COM Method activity, which is an Object type converted using the .ToString method.

No alt text provided for this image

Because the Illustrator script uses JSON.stringify() on the data it passes to its final global variable, the result of the Invoke COM Method activity will contain this string in its result variable which has to be an Object type, even if it’s really a string.

During the run, UiPath executes the Illustrator javascript and Illustrator springs to life, automatically opening and editing the artwork assets. If all went well, the result of the execution is stored for usage in the next sequence.

8. Flow Decision

This Flow Decision evaluates whether the string variable which is destined to house the Illustrator script result is empty or not. If this variable is found to be empty, the workflow stops as there is nothing left to do. But if the opposite is evaluated, it’s the green light to send an HTTP POST request back to the Google Sheet to inform it that the process has been successfully completed.

No alt text provided for this image

9. PostToGS Sequence

Finally as the workflow has been found to have successfully ran the Illustrator process, this sequence takes care of the task of sending a message back to the Google Sheet script which will then update the product data spreadsheet with some information coming from this RPA process.

This sequence contains only one activity: the HTTP Request. It could have just been outside the sequence container as well.

No alt text provided for this image

The most important part of this activity is its Properties panel where specific items have to be set in order to ensure a successful POST request to Google Sheets. This request would be handled by the GScript’s doPost method which can access the requests’ body with the .postData.contents property.

The proper method POST must be chosen in the Input section, as well as the URL.

No alt text provided for this image



In the Options section, the post body is specified. The Body variable is set to the JSON string produced from the previous Illustrator sequence. The proper BodyFormat selection for this case is “application/json”.

No alt text provided for this image



When the POST request completes, the Google Sheet script fills in the appropriate cells in each affected product row with the last RPA timestamp, result status code and the result message.

No alt text provided for this image
No alt text provided for this image

Let’s do a full run-through. The Google Sheet is populated with the previous results, and the User/RPA timestamps are identical for all product rows because during the last run the “Last RPA Update” values were blank. Running the UiPath bot now will produce the message that no rows eligible for changes were detected.

No alt text provided for this image

Now let’s delete the “Last RPA Update”, “Status” and “Result Note” data for all the product rows and also replace the current artwork files with non-processed templates in the backup folder.

No alt text provided for this image
No alt text provided for this image

And let’s run the UiPath workflow again.

Now, Illustrator processes each file by changing the default text in appropriate textboxes to the data fetched out of the Google Sheet.

When it’s done, the Google Sheet automatically fills up with the workflow’s result data. Each affected product row gets the RPA timestamp (and same user timestamp in the case of the RPA timestamp being an initial blank), a status code and a summary of changes.

No alt text provided for this image

Now let’s make a change in the Google Sheet and update the “Calories” in product “123455” (Apple Juice). I changed it from 250 to 300.

No alt text provided for this image

As soon as the cell is tabbed off, the “Last User Update” column reflects an updated timestamp.

No alt text provided for this image

It’s been over several minutes’ difference between the two timestamps, so the next time the UiPath workflow runs, it should process this product. Let’s run it again.

Now the product row is updated to show the latest changes.

No alt text provided for this image

And in the Illustrator artwork, it can be seen that the “Calories” textbox shows the new number “300”.

No alt text provided for this image

Now let’s test the handled error portion of the workflow by deliberately causing a condition which will trigger an error within the realms of the Illustrator script’s try-catch blocks. One such error is thrown by the code when no text frames are found out of all the possible ones which are meant to be changed by this process.

    if (foundItemCounter == 0) {

      throw new Error("No named text-frames matching data properties were found in file '" + decodeURI(productFile) + "'.");

    }

With the above code, the error message will be caught by a catch statement and added to the results log of the batch process. Throwing an error causes the execution to stop right there and any following lines would not be called. Therefore once this document has been opened up, it will remain open for examination while the rest of the batch can be processed as normal. So let’s go ahead and delete all the names of the named textboxes in the Apple Juice file.

No alt text provided for this image





No alt text provided for this image



Once the text-frame is un-named, it will show its text content where the name used to show inside the Layers panel.

Now I’m going to save the document and go back to the Google Sheet to make some kind of user-change.

No alt text provided for this image

With some of the records’ “Last User Update” timestamps now updated to be later than the RPA one, let’s launch the UiPath workflow once again.

The results show an ERROR status code for the “Apple Juice” product. Notice the error message is the actual error thrown within a try-catch block inside the Illustrator script.

No alt text provided for this image

Simulating a user corrective action, I’ll replace the “Apple Juice” file back with the properly working template which has all the correctly-named textboxes and manually remove the “Last RPA Update” timestamp from the Google Sheet. Then I’ll re-run the UiPath bot.

No alt text provided for this image

And after the bot runs, the product row reflects the successful update:

No alt text provided for this image
No alt text provided for this image

Conclusion

This DIY method of pairing collaborative data to art assets could be the versatile solution a competitive business needs for streamlining some operations. It could be used to prototype an integration with a future DAM or PIM, etc system.

It would be interesting to try and leverage computer vision for some purpose within a workflow like this.




Ray Karle

Automation Specialist | Pre-Press | Graphic Designer | Preflight

7mo

This is great! I want to look at this and see if we can implement something like this where I work. I know Im a little late to the party.

Ramon Padilla

Graphic Design / Production Artist

4y

Joey Lopez I’m going to look into this a little closer, it might be a great solution for sell sheets. It’s that pathway we need to make them straight up automated.

Joey Lopez

Creative Director, CMF, & Additive Manufacturing Expert | xTurtleBeach/PDP/Victrix xDisney xApple

4y

Check this out Ramon Padilla

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics