Setting the value of a field with automation

I am curious if anyone else has run into this issue, and what you may have done to overcome it. I created a set of dashboards for a customer, to help them enter new clients into a Form. When they click the Submit button the new customer info is added to a SQLite database. All of this is working in the latest version, and has been for some time.

I was asked to look at adding some automation. The basic steps are to read through a specific mailbox, pull emails with a specific subject and PDF attachments, OCR the PDFs for the desired data, and then input it into this form, instead of a human having to do it. Everything up through filling the form also works as I would expect. The problem comes in when I click the Submit button, and it attempts to add the data to the SQLite db.

I am using a number of statements like (Get-UDElement -Id “Address1”).Value to input data to the db, and this works every time if I manually type info into the different fields. With the automation, I am getting the XPath of the field, and setting the text of that field to what I want via the info pulled from PDFs. When done through the automation, however, the .Value of the field remains blank - it is like it isn’t being populated unless you manually type into the field. I have tried various delays; thinking I was going too quickly or something, but none of it has helped. I am just curious why the fields would not populate the .Value parameter when filled through automation, and if there is something that can be done to “refresh” the element?

Product: PowerShell Universal
Version: 2.5.4

If you could share some code on how you’re setting those fields that may help people identify the issue.
Are you using set-udelement ?

Sorry for the delay, have been out of town. The customer is using an RPA product for the automation, Automation Anywhere, to be exact. The tool obtains the XPath of the element and then uses either a Copy Paste function (if no delay is selected) or keystroke simulation (if a delay in ms between each key press is selected) to insert the text into the field. Filling the fields works just fine:

But I have the “Add Client” button set to show a Toast of each element’s value on click:

        New-UDButton -Id "Add" -Text "Add Client" -OnClick {
            Show-UDToast    (Get-UDElement -Id "taxID").Value
            Show-UDToast    (Get-UDElement -Id "first").Value
            Show-UDToast    (Get-UDElement -Id "last").Value
            Show-UDToast    (Get-UDElement -Id "inbox").Value
            Show-UDToast    (Get-UDElement -Id "webpage").Value
            Show-UDToast    (Get-UDElement -Id "street1").Value
            Show-UDToast    (Get-UDElement -Id "zipcode").Value
            Show-UDToast    (Get-UDElement -Id "statecode").Value
            Show-UDToast    (Get-UDElement -Id "street2").Value
            Show-UDToast    (Get-UDElement -Id "cityname").Value
            Show-UDToast    (Get-UDElement -Id "phonenumber").Value
            Show-UDToast    (Get-UDElement -Id "faxnumber").Value
            Show-UDToast    (Get-UDElement -Id "comments").Value

But they all show as null, from the standpoint of PSU:

I also tried pulling the value of the element through Javascript, like so, and it DOES work. PSU, however, doesn’t see the value:

image

If I manually copy the values out of Notepad and paste them into the page, it works. It just seems, for some reason, that if I do it through automation - whether a copy and paste or simulating keystrokes, PSU does not get the value of the element. If I click on one of the elements that is not reading, and add a character manually, then PSU seems to refresh the .value of it.

Not really familiar with automation anywhere.
But as far as PSU goes this code works:

New-UDDashboard -Title "Hello, World!" -Content {

    New-UDTextbox -id "taxID" -Label 'Tax ID' -Placeholder 'Textbox'
    
    New-UDButton -Id "Add" -Text "Add Client" -OnClick {
        $Value = (Get-UDElement -Id 'taxID').value 
        Show-UDToast -Message $Value
    }
}

Obviously, if the textbox has no value, then getting an error stating message is an empty string or null is actually expected in this case.
If that’s not what you want, and you still want a toast popup that shows if it’s empty or not, then you’ll need to provide a valid string to your show-UDToast like this:

New-UDDashboard -Title "Hello, World!" -Content {

    New-UDTextbox -id "taxID" -Label 'Tax ID' -Placeholder 'Textbox'
    
    New-UDButton -Id "Add" -Text "Add Client" -OnClick {
        $Value = (Get-UDElement -Id 'taxID').value 
        Show-UDToast -Message "Message: $Value"
    }
}

Just re-read your post, I’d hazard a guess that whatever your automation is doing outside of PSU, it’s not fully triggering event handlers that are required for PSU - especially if you can replicate and make this work manually, to that effect I’d suggest it’s more an issue with what the external automation is doing - or not doing, as opposed to anything PSU side.

Thanks for the replies. There seems to be a delay in the event handling triggers on the PSU side. As I mentioned, if there is no delay in setting the element value, it performs a copy/paste. If you set a delay it uses keystroke simulation to fill the field. I found I have to set a pretty high delay (~40 ms per keystroke) before PSU sees the value. Still playing around with ways to speed this up, but I have something to go on at least.