Send parameter from web to uipath worflow

Hi,
I need to send from web page (textbox) (by post method - HTML - Javascript) the string that user has typed to uipath workflow, is there any step by step or video, I’m new in this

This video will help you get in the right direction: User Events and Agent-Assisted Automation in UiPath - YouTube

Since the application you’re interacting with is a web-based application your use case is different and thus injecting JavaScript might be the most ideal way of intercepting the form submission.

2 Likes

Tks Im going to watch it!!!

@OpalSnow, I saw it and still I dont know how to do it, in my case I have a web site for anybody, so it isnt a scrpping data, my case, the robot is called by a trigger or process using i dont know python, I just want to know how do I do to send it by javascript from front to back as you do when you save data from form into database

This is quite tricky. At least I am not aware of how to easily intercept a form submission in UiPath. I’ve come up with a rather dirty way of getting it to work.

Note that this does not work on Chrome. It might on Firefox I have not tried it. It works on Internet Explorer.

Start off by injecting the following javascript code into the browser using the Inject Js Script activity

function() {
	
	var FormSubmit = false;

	document.addEventListener("submit", function(e) {
		FormSubmit = true;
		setTimeout(function() { FormSubmit = false; }, 1000);
	});

	window.onbeforeunload = function() {
		if (FormSubmit)
			return "Waiting for UiPath...";
	}
	
	// This will prevent the "_clientFunc is not a function" exception
	return function() {};

};

This javascript code will make it so a popup is being shown when a form is submitted. It will show: “Waiting for UiPath…”. See image below:

afbeelding
In UiPath, use the Element Exists activity (or On Element Appear if you prefer that) to find this popup with the text “Waiting for UiPath…”. I used this selector:

<wnd app='iexplore.exe' title='Windows Internet Explorer' />
<wnd aaname='Windows Internet Explorer' cls='DirectUIHWND' />
<ctrl name='Windows Internet Explorer' role='pane' />
<ctrl name='*Waiting for UiPath...' role='text' />

Set an appropriate timeout for this activity and if an exception occurs and the element could not be found, repeat to find the “Waiting for UiPath…” element until one is found. I recommend using a Flowchart to easily repeat the Element Exists activity.

If the element is found, this means a form is submitted. Now fetch the input values on the website using the Get Text activity. The “Waiting for UiPath…” popup prevented Internet Explorer from submitting the form so we can still read the form’s input values. Once you have all the input values you want, continue by clicking the “Leave page” button using the Click activity so the form gets submitted. The selector I used to click the “Leave page” button is:

<wnd app='iexplore.exe' title='Windows Internet Explorer' />
<wnd aaname='Windows Internet Explorer' cls='DirectUIHWND' />
<wnd cls='Button' />

Now your robot is in a state where you have the submitted form input values and the form is submitted. Any further logic like looking for a success message could further be built into your robot.

There could be other, better ways to do this. I haven’t come across nor come up with one yet. Once I do I’ll be sure to update this topic.

1 Like