PowerApps support web files. You can upload custom images, files, spreadsheets, and more. But when it comes to javascript files, it shows an invalid file type error.
The reason is that web files are notes with attachments. These notes are stored in the dataverse or the Dynamics instance. As for .js extension files, they are mostly blocked from upload due to security issues. Even if it’s possible to upload and open .js files, you shouldn’t, for the same security reasons.
If you want to upload a custom javascript file, here’s what you should do:
→ Log in to the portal with the administrator role.
→ From the portal editor box, click on New -> Child File.
→ Create a new child file pop-up will open.
→ Click on the Upload file option and choose the .js file from file explorer.
→ Select the attachment option in Content-disposition and click on save.
→ Click on the portal editor box -> Children to view the uploaded file.
You can also view the uploaded .js file in the Dynamics CRM customer portal management app in CRM.
→ To view uploaded .js files, go to Portal Management App -> Web Pages.
→ Open the web page from where you have uploaded the file.
→ Click on Child Files & search uploaded file.
→ You can see the uploaded file in the file record or notes as a note attachment.
→ If note attachment is not found, or you get the below error while uploading a .js file in notes, then check blocked file extensions in CRM.
→ To verify/allow .js file extension in CRM, go to Settings -> Administration -> Click on System Settings.
→ In General Tab -> From Set blocked file extensions for attachments list, check & remove .js file extension and save it.
Whenever you upload a web file, it is uploaded as a note attachment in your CDS/Dynamics 365 environment, and more often than not, it is not a comprehensive solution.
But from now you can use uploaded .js globally by adding js reference in pages with below script reference.
< script type="text/javascript" src="~/sample.js" >< /script >
Note: My web file is under the Home page, and hence I have used the path accordingly. However, if your path is different, you may need to change the src value accordingly.
I hope you found this article helpful. Stay connected to know more about the Dynamics CRM customer portal.
All product and company names are trademarks™, registered® or copyright© trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.