cancel
Showing results for 
Search instead for 
Did you mean: 

How can I manipulate a webpage textarea through HTML insertion/manipulation.

Hi everyone,

I was hoping someone can provide some technical insights in how to interact with a webpage. I need to send an email to customers through the internal mailservice of the SalesForce classic webpage. To do this a couple of fields need to receive input, like To, Send on behalf of, Subject and main text. I have already automated this through the normal BP options and it works fine.

However now I find that in the manual workflow a template is used which is called by our employees through a SF button on the email webpage. The template includes a picture and also a couple of different regions with regards to text formatting , styling and hyperlinks. This means that I can not just fill the textarea in the normal way but have to include the required formatting, hyperlinks and the image (our company logo).

I now see two options to achieve this:
1) Copy the entire template text, manipulate it, and paste it back in. 
2) Insert/Inject/Change/Manipulate the HTML of the webpage by which the template would be recreated. 

My preference is option two as it allows for more control and will be more robust I think. Also the final make-up of the text can be checked more accurately. However I don't see how I can do this? I know how to retrieve specific data from a webpage using an HTML snapshot and C# combined with things like regex, HTMLAgilityPack etc., but I have no idea how to then interact with an existing browser to change it's contents programatically. If I then also have to translate this capability into BP I am lost even further. 

I have done some searching on Google and this forum, and I might be looking for inserting or invoking Javascript fragments? However I can't find any explanation as to how this works either within BP or outside of it. 

Can anyone point me in the right direction? Maybe someone knows a method for interacting with a webpage on this level, or otherwise maybe tell me some keywords or give me a link or something?

Any help is much appreciated!

Kind regards,
Thomas.

P.S.
I can't use outlook because the correspondence has to be visible in SF, and we don't have access to the SF API so I don't see another way to do it then through SF itself.
1 REPLY 1

NicholasZejdlik
Level 9
I believe the Blue Prism answer to these kinds of issues is the insert/invoke Javascript functionality. As an example for using Insert Javascript Function and Invoke Javascript Function, try this:

Insert Javascript Function, Fragment: "function doSomething() { alert('hello'); Success = true; }"
Invoke Javascript Function, Function Name: "doSomething", Arguments: "[{}]" (an empty JSON array)

This does work for me, it displays an alert saying "hello". The challenge would be determining the javascript you need to run in order to manipulate the webpage correctly. I would recommend testing in your browser's dev tools before copying any code into Blue Prism; the errors that it gives related to javascript are not helpful.

On a side note, there is a library Microsoft released for .NET called Playwright. I have found, when you need finer control than Blue Prism natively offers, it can be easier to run things through Playwright. There are a lot of upsides to it, but the downside is that it cannot interact with an existing browser, so you would not be able to mix and match it with Blue Prism functionality; just one or the other. (Also, I could not get the library to work within a Blue Prism code stage, so instead I have a network folder containing Playwright applications that I call from Blue Prism.)