Sending values into the "Custom Input" activity

I want to show a form so that the user fills it and my bot does the rest, I want to make the user do as little work as possible, so I’d want the form to be pre-filled so the user can check if it’s right, do the needed modifications and submit it. Is there a way to send the data into the activity?

1 Like

Hey,

I think the easiest way to pre-fill the form is to give your input tags default values like this:
https://www.w3schools.com/tags/att_input_value.asp

If you really need to send data into the form, you would need to send parameters via the input URI and use them in the code of the form like this:
https://www.xul.fr/javascript/parameters.php

Find the activity documentation and a sample html here:

Let me know, if this helps.

Hi,
First of all thanks for your reply.
I really need to send the data since It will only be determined when the bot is running, so I tried via URI, but the URI field of the Custom Activity doesn’t recognize the “?” symbol.

Hey,

it seems, that passing arguments via the URI is not possible yet, I was mistaken - sorry.
Check out this thread, the functionality is being considered for a future release:

Thanks, I will try the replacing string method on the html file.

I have found a workaround.

As it is a local html file, I have to extract the parameters directly from the url (no server is involved and Cross Site Scripting is not an issue).
So i tried another character instead of “?”, like “#”.

ACCESS:
[path to the file]\mywebform.html#param1=1&param2=2

CODE:
I am using an onload method

1 Like

function processParameters()
{
// Get params string
var url = window.location.href;
var paramsInitIndex = url.indexOf(’#’);
var paramsString = url.substring(paramsInitIndex + 1, url.length);

// Handle each parameter of params string
var parameters = paramsString.split("&");
for(i=0; i<parameters.length; i++){
	handleParameter(parameters[i], i);
}

}

function handleParameter(value, index) {
var param = value.split("=");
var paramName = param[0];
var paramValue = unescape(param[1]);
alert("Param name: " + paramName + ", " + "Param value: " + paramValue);
}

1 Like

hi @juansaenz
I have tried the code you posted, but yet i am not able to display the value. Could you please help me.

I used that script inside the head mark and called processParameters() on body onload event. You are including the script inside the body. Debug using alert() function inside javascript.

<html><head><script type="text/javascript">...here the script...</script></head><body onload="processParameters();">...here the body...</body></html>

By the way, i have noticed that you are using a form with a local php file… That won’t work because it is a local file.
Furthermore, if you want to pass the data back to the process, you have to set result json in your submit function:

If you had an input like this <input type="text" id="myfield" name="myfield" /> it would be:
var variablevalue= document.getElementById(“myfield”).value;
window.external.setResult("{‘name’:’" + variablevalue+ “’}”);

If you try it, let me know.
Happy coding.

1 Like

hi @juansaenz i tried this. everything worked!
thank you so much for the detailed steps! :clap: