Trouble Embedding HTML with Variables in UiPath Assign Action

I am migrating an automation anywhere workflow to UiPath. Part of the workflow includes embedding HTML code within a loop into an assign action (string). It was very easy to do in automation anywhere as I just copied and pasted the code into a string assign action and I was able to embed variables within the HTML code and get those variable values while looping. In UiPath, I am getting a ton of errors when attempting to do this.

I can provide a sample of the HTML I am using below. I used w3schools TryIt Editor to make sure the HTML code is working as expected:

HTML Code:

table, th, td { border: 1px solid black; border-collapse: collapse; font-family: Calibri, sans-serif; } th, td { padding: 4px; } th { text-align: left; } p { font-family: Calibri, sans-serif; color: black; } .bold-text { font-weight: bold; font-size: 1.5em; } .just-bold { font-weight: bold; } .underlined { text-decoration: underline; } .center-text { text-align: center; } .red-text { color: red; } .italic-text { font-style: italic; }

PLEASE NOTE – FOR BOOK RECOMMENDATIONS, PLEASE DISCUSS WITH YOUR BOOK CLUB LEADER.

Hi $sRecipientToFirstName$ -

This month’s Book Club Reading List is now available. Please work with your group to discuss these selections. You can view the entire list here: Book Club Reading ListI

Disclaimer: If a table below appears blank, it indicates that there are no book selections for that particular category.

Current Reading List (Selected by club members):

Note: If the “Members' Choice” column is empty on the website, it means the selection is yet to be finalized. Ensure to cast your votes or suggest new titles as needed.

Please feel free to ask me any questions in regards to this topic.

Thank you in advance!

Book Title (ISBN) Genre Discussion Leader Next Meeting Date Member's Choice Currently Reading Top Recommendation Meeting Notes

Hi @TonyO,

Try having your complete html code in a text file with place holders, Read the text file and replace the place holders with your variable using Replace function. In this way, it’s easy to maintain and update the HTML code.

Example:

Text File Code:

image

Read the above text file and the output will be string.

In the assign activity you can use:

yourOutputVariable.Replace(“{{header1}}”,variableHeader).Replace(“{{paragraph}}”,variableParagraph)

This is a simple example. In case of tables, you might have to do it with logics of assigning the opening and closing dr and dt tags according to your requirement.

My suggestion would be to start with simple table with 1 or 2 rows just to build the logic and then you can expand it for many.

Cheers

Have a look at this activity

which is supporting Variables out of the box

the link to the used HTML Template file can be checked here:
grafik

and can also be edited manually (assumption: HTML Skills are present)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.