Javascript Custom Input activity: querySelectorAll

Hi, guys.

I’m trying to use document.querySelectorAll inside a HTML file read by Custom Input activity and it’s showing me the following message: “Object doesn’t support property or method ‘querySelectorAll’.”

I want to select all checkboxes associated with a class named OCC through one single checkbox.

HTML:

imagen

JAVASCRIPT:
function OCC(source) {
checkboxes = document.querySelectorAll(’.OCC’);
for (var i = 0, n = checkboxes.length; i < n; i++) {
checkboxes[i].checked = source.checked;
}
}
I’ve searched and I’ve come across multiple solutions but none of them worked. I guess it’s because none of the previous answers were framed in a UiPath scenario. Do any of you know a workaround?

Thank you

@franrua02
a first look lets interptetate that the query is searching for elements with the class OCC (indicated by the used dot). But your shown input html snippet is different

so run this statement before in browser web tools (F12) javascript console and check if its returning anything.

We made the best efforts by not changing the function argument names. So let it b the name as used in the documentation from uipath

Hi, thank you for answering.
It’s different (doesn’t have OCC class) because that’s the checkbox that triggers the function OCC when clicked.
I can’t show the whole code because of confidentiality issues but since a misunderstanding arose, I decided to replicate a snippet of the code just as if it were to be used as an argument of the custom input activity:

https://jsfiddle.net/franrua/3g4cjvus/10/

I hope this clarifies any misunderstanding.

@franrua02
thanks for your feedback.
Confidence and Security Compliance is a must and never will be short cut.

document.querySelectorAll(’.OCC’);

please have a look on this part. The code part is focusing on elements with class name OCC
not found in the html snippet

If my answer is not matching then we just shift the case to the next day

I’m sorry but I don’t seem to understand why you keep telling me there are no elements with class name OCC in the HTML, when in fact I added four of them. (right below a snippet of the code I took out of the URL provided before )
Although I muss add that even if it were the case - no element with class ‘OCC’ - it shouldn’t be a problem since no checkboxes would be selected.

input class="OCC" type="checkbox" name="checkbox" value="1" />1 <br>
  <input class="OCC" type="checkbox" name="checkbox" value="2" /> 2<br>
  <input class="OCC" type="checkbox" name="checkbox" value="3" /> 3<br>
  <input class="OCC" type="checkbox" name="checkbox" value="4" />4<br>

@franrua02
I did just overlook. Thanks for your hint.

The issue could come from some compatibilty differences. But was solvable by forcing to IE11 level. Checkout the line in the HTML meta section.

With this I was able to get it working. Find demo here.
CI_WithCheckBoxes.xaml (4.3 KB)
and html here:
CI_CheckBoxes.html (1.3 KB)

2 Likes

OMG! Thank you! <3

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