Pass variable into a textfile

Hi Everyone,

i have a textfile whic is actually a html code and i want to pass the variable value into one of the textbox in the codefile.
Variable is : varamountDue with default value “100”
The textbox where i want to pass this variable in the code is
input type=“number” id=“amountDue” required=“true” name=“amountDue” placeholder=“0.01”

in the id attribute i want to pass this variable : varamountDue HTMLPage1.html (5.6 KB)

When you post code put a backslash before the tags to escape them:
<input type=“number” id=“amountDue” required=“true” name=“amountDue” placeholder=“1.0” step=“0.01” min=“0”>

You can also mark it as preformatted text and it will show like this:
<input type="number" id="amountDue" required="true" name="amountDue" placeholder="1.0" step="0.01" min="0">

To put the variable in your html file do the following:
Use a Read Text File activity to read your html into a string variable, let’s call it fileText. Then use fileText.Replace to replace the placeholder text with your variable value. Finally, write the modified to text back to the file with a Write Text File activity.

just trying to do do what u said

can you please tell how it will be replaced as my formatting is giving errors

Can you show me exactly what you want the input tag to look like?

<input type="number" id="amountDue" required="true" name="amountDue" placeholder="@vamountDue" step="0.01" min="0">

where @vamountDue will be the value fetched from the webpage which can be 123,234 etc

In that case you would do fileText.Replace("@vamountDue",varamountDue). Note the quotation marks - this will replace any copies of “@vamountDue” with whatever value is in varamountDue. If varamountDue is a numerical type then you will need to use varamountDue.ToString in order to write it to the file.

but this will be blank like this
<input type="number" id="amountDue" required="true" name="amountDue" placeholder="1.0" step="0.01" min="0">
Bot has to fetch value from webpage ,save it in vamountDue and pass this into this textbox of Customform

The html file is just text, you can make the placeholder value anything that you want. Get rid of that “1.0” value and put some placeholder text in there. Then modify the file with Replace before you open it with the custom form activity.

can you please provide sample of it if u have any.

i tried this in Write Text File activity customOutput.Replace(“placeholder=test”,“placeholder=”+vtest)
where vtest=100 but still it didn’t ammend the placeholder value to be 100

Try this out.
Main.xaml (6.5 KB)

This does modify the file so to keep being able to fill in the placeholder you should have a “base” copy and a “modified” copy so that the original always has the placeholder text. Otherwise the replace won’t work.

i tried to run your code but it didn’t modify any placeholder value
can you please try to run from your end?

please find attached code in which the placeholder value need to be replaced with the variable valueNewPage.html (5.6 KB)

It modifies the text on the button to match whatever input you give, I just used an existing html form I had laying around.

Main (7).xaml (6.4 KB)

I made changes in your xaml…and gave path of the file and the textfield i need to pass variable value…but still it didn’t show value in the Html page

it worked for me once, but I want the BOT to overwrite the newvalue passed through inputdialog overwrite the previous value.But it is not overwriting that


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