Dynamically change the HTML Tables TD background color

Dear all,

Can someone help me to change the background color of HTML table td based on certain condition?

If the condition is True the background color of the td should be Green and if the condition is False the background color of the td should be Red?

I have seen a post which is very much similar to my requirement(mentioned below), but I did not get the expected result.

<p class=MsoNormal><span style='background:red;mso-highlight:red'>ABC</span></p>

Please help me with a sample code.

Thanks
Deepak

“p class=MsoNormal span style=‘background:“variable”;mso-highlight:“variable”’ ABCspan></p”

change the red to a variable name and assign red and green via different situation?

maybe need to add & or + before and after the variable

Tried as per your request still there are issues. Attached is the screen shot of the error what i am getting.

Hi @Deepak_Andriod

Hope below code will give some idea

strTable as string
strTable = "<table>"
if(true) Then
strTable=strTable+"<td style='background:green;'>Success</td>"
else
strTable=strTable+"<td style='background:red;'>Failed</td>"
End if

Thanks but where should I paste this code?

Can I do it on fly?
I just want to change it over here
UserData.Replace(“varService”,varServicePass).ToString

grafik
want something like the attached. Attached is from the following link.

What are you doing in your requirement?

Check out this Sequence2.xaml (6.5 KB)

I have a HTML Template(saved as a .txt file) and I am passing the value to the .txt file using
UserData.Replace(“varService”,varServicePass).ToString
Using the readtext file I am getting the data in UserData

change your color in HTML template to variable, after that, read the HTML template and use .replace to replace it.

@Deepak_Andriod The idea is keep two different html file for Green and Red background based on the condition pick the right file.

Ok thanks i am going through your code and changing my code accordingly.

I want something like what is shown in the attachementSample

Got the idea from your code…I will have to change a lot… Let me try and will get back to soon.

Logic is you have to add the style based on the Column “EmpAttendance” on that td add the background color dynamically like the code I shared.

now there is another issue, if there are 100 rows, how can I do this?
Your logic and the code provided is absolutely working fine.

Use for each row in datatable activity to loop every row and add the style.

I have another doubt, using UIPath is it possible to transform webservices? Is it possible to convert SOAP to Restful?

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