cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akersk
New Member

File input on form - how to lock? (PowerApps, model driven)

Hi everyone,

We're using PowerApps to build a model driven app that uses the "file" type column in a table. As I understand it, this option hasn't been available for model driven apps for very long. The file upload control on a form works fairly well. It takes the selected file and stores this directly in the appropriate Dataverse table column. However, we cannot disable this file input with a business rule somehow. Business Rule editor simply doesn't give the option.

Knipsel.PNG

The plan is to use JavaScript to disable the input when it needs to be disabled. The JavaScript however does not get access to the targeted section (containing the button input we need to grab) using id (getElementById). The section ID can be controlled from the classic form edit view. So, if the section is grabbed, we can then search for the button and disable it. But the section appears to be generated after the onLoad event finishes. The result is, that I can grab the section when I run "document.getElementById('my_specific_section_id')" from the browser console, but when the application executes the script, it always results in null.

The section can't be found. This is only the case when using the file input form field. Other elements can be found as expected. In Dynamics365 user groups I was reading about how getlementById is not supported there. But given the fact that I can use this to grab other elements, I think it is not the case here.

What can I do to get the file input field disabled (as in "locked", unable to select a file, or delete one if one is already there)?

Best regards,
- Alex

1 ACCEPTED SOLUTION

Accepted Solutions
akersk
New Member

The answer, in my case, was to use formContext.getControl. A user on another forum was so kind as to put me in the right direction. Thank you.

View solution in original post

1 REPLY 1
akersk
New Member

The answer, in my case, was to use formContext.getControl. A user on another forum was so kind as to put me in the right direction. Thank you.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,637)