web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / set checkbox on web fo...
Power Automate
Answered

set checkbox on web form - how to select correct one

(0) ShareShare
ReportReport
Posted on by 17

Hi, first of all I would like to thank anybody willing to help me with my problem.

 

I need to fill a web form and there are a lot of records to add. Therefore I would like to automate the work.

I read the data from CSV file, and then need to populate the web form with retrieved data in loop.

The thing is that some fields are combo-boxes containing checkboxes. One such field is Country.

If I just populate country name to the appropriate textbox and then try to submit the form, I get an error that no country was selected. I actually have to check the corresponding checkbox.

 

This is how my flow looks like right now.

prorokrak_0-1638128966637.png

  1. It populates the country name to the text field. However, this step does not actually change anything. It does not check the checkbox of the country. Neither it scrolls the combo-box to the appropriate country. Thus, it is probably unnecessary.
  2. It clicks on the arrow to actually show the list of countries.
  3. It always checks the item that is on the top of the list.

This is what the selector chkPartiallyWorking looks like:

 

div[Id="ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_DropDown"] ul[Class="rcbList"] label > input[Class="rcbCheckBox"]

 

 

And this is screenshot from the browser.

prorokrak_2-1638129722980.png

 

Is it possible to check the correct checkbox with Power Automate Desktop? And how should selector look like? Or any alternative ideas how I can achieve what I need?

 

I have the same question (0)
  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    What happens if you click on the name in the list ?
    This is a list item, and could possible be set by using

    Highboy_1-1638130402555.png

     

  • prorokrak Profile Picture
    17 on at

    When manually clicking on the label (country name text). it checks the item.

    However, the "Set drop-down list" action does not work. I have tried two selectors:

     

    This selector highlights with yellow topmost item (the whole row with the country Australia), even though I have chose Belgium. However, it does not check the checkbox.

     

    div[Id="ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_DropDown"] > div[Class="rcbScroll rcbWidth"] > ul[Class="rcbList"] label

     

     

    This selector highlights with yellow all items in the list:

     

    div[Id="ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_DropDown"] > div[Class="rcbScroll rcbWidth"]

     

     I have tried both Select options by name/by index but neither worked.

  • Highboy Profile Picture
    1,187 Super User 2024 Season 1 on at

    Do you have a link to the webpage or is it a company webpage?

  • VJR Profile Picture
    7,635 on at

    Hi @prorokrak 

     

    - There is a space at the end of the country names For eg; "AUSTRALIA ".

    Hope you have considered that in whatever you have tried so far. If not, please redo the tests with the extra space.

     

    - Another option is to use the "Run javascript function on webpage" action in PAD. Try and see if you can trigger the checkboxes using that.

     

  • prorokrak Profile Picture
    17 on at

    It is a company webpage, login is necessary.

  • prorokrak Profile Picture
    17 on at

    @VJR wrote:

    Hi @prorokrak 

     

    - There is a space at the end of the country names For eg; "AUSTRALIA ".

    Hope you have considered that in whatever you have tried so far. If not, please redo the tests with the extra space.


    Yes, I took the spaces into account. Actually, every country is right-padded with spaces to have the same number of characters. Therefore,

     

    Australia is actually 
    "AUSTRALIA ", Belgium is actually 
    "BELGIUM "

     

    That was also the reason why I tried to use indices.

     

    The suggestion "Run javascript function on webpage" sounds interesting to me but I do not know what function I should run. Could you be more specific, please, how should I use it?

     

    Thanks for your effort and time.

  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @prorokrak 

     

    The action is used to interact with the elements on the webpage via javascript.

    Some example videos on what/how it can do.

    https://www.youtube.com/watch?v=mwCwmbdUcgA

    https://www.youtube.com/watch?v=E-WE9BpneOM

     

    The second screenshot in the post that is marked as an answer shows how the action is used to tick a checkbox element.

    https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Set-radio-button-checked-by-using-Run-Javascript-function-on-web/m-p/829013/highlight/true#M1424

     

     

  • prorokrak Profile Picture
    17 on at

    Thank you for the interesting resources. I will try this approach and then get back to let you know how it went.

  • prorokrak Profile Picture
    17 on at

    I have tried the JavaScript method but without success.

    I have adjusted my flow like this:

    prorokrak_0-1638203997568.png

    My JavaScript code reads:

     

     

    function ExecuteScript() { 
    //Hard-coded a specific country for testing purposes
    var checkbox = document.querySelector("#ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_DropDown > div > ul > li:nth-child(3) > label > input");
    checkbox.checked = true;
    checkbox.setAttribute("aria-checked", "true");
     }

     

     

     

    Already the first action successfully checks the checkbox, as well as sets the attribute "aria-checked".

    The other commands were more like to be on the safe side (show the combo box, populate text field with country name, hide the combo box).

    Still, when I press Submit, I got an error "No country selected".

     

    At first, I did not set the attribute "aria-checked" with JavaScript but I got the "No country selected" error. So I thought the attribute could make the difference but it did not.

     

    I have no idea what else is going on there - why I have to click on the country to have the form accepting the country.

     

    Any other suggestions what I could try?

  • prorokrak Profile Picture
    17 on at

    Finally, I was able to solve it. There was another part of the page that was updated when clicking the combo box. It was tricky because it was at a different place in the html code.

    prorokrak_0-1638210320242.png

    I had to update these values as well in order to get the form working.

    function ExecuteScript() { 
    var checkbox = document.querySelector("#ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_DropDown > div > ul > li:nth-child(3) > label > input");
    checkbox.checked = true;
    checkbox.parentElement.parentElement.setAttribute("aria-checked", "true");
    
    var setInput = document.querySelector("#ctl00_Body_GridView1_ctl00_ctl02_ctl03_Ins_RadCountry_rcbDBCBox_ClientState");
    setInput.setAttribute("value", '{"logEntries":[],"value":"","text":"BELGIUM ","enabled":true,"checkedIndices":[2],"checkedItemsTextOverflows":false}');
     }

    Now I need to figure out how to make the JavaScript code dynamic.

    But in the end, the JavaScript function was way to go.

     

    Thank you for pointing me in the right direction.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 791

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 535

Last 30 days Overall leaderboard