How to disable field based on condition on form load in uipath forms?

Viewed 563

I came across a problem where if a field has value already present, it needs to be disabled.

I tried to use Logic with simple JavaScript trigger but I’m not sure when this trigger is evaluated, but the trigger is executed onchange or onblur.

Trigger: enter image description here

Action: enter image description here

This works but since trigger executes onblur or onchange, as soon as I type some characters the field is disabled.

It should execute only once on form load. I have tried adding a hidden HTML component but calling the onload function is not working.

HTML component code:

<!DOCTYPE html>
<html>
<body onload="myFunction();">
<script>
function myFunction() {
if(document.getElementById('empName').innerHTML.length > 0)
  {
    document.getElementById('empName').setAttribute('disabled ', 'disabled');
  }
}
</script>
</body>
</html>

I'm not very good with JavaScript or have used form.io before. Also, I could not understand how to use Trigger type Event and call it externally. Thanks for the help.

1 Answers

You can set the dependent field by:

  1. Setting the logic trigger to be of 'Simple' type and check the parent field to have '' (blank) value.
  2. Have the logic action setup as you have already done

enter image description here

Related