I’m having problems trying to call javascript from a portal page. Ultimately the button click will run an Azure function.
But for now I’ve stripped this right back to basics with a very simple example to display a message when a button is clicked, but nothing happens. I’m missing something obvious I’m sure?
The javascript resides in the Custom Javascript section of the Advanced option of the web page
And the HTML for the button is in the Web Template used by the page
And the button appears on the page
Thanks in advance
Yeah, "sync configuration" and "clear cache" would be sort of the same thing.
To access the clear cache under the _services/about page, you need to make sure your Contact/User record has the Administrator Web Role associated.
Anyways, I am glad you got it working, can you please mark the solution in case other people are facing the same issue ?
Hi Fubar, got simple click working, my bad, syntax for click was missing () after the function, school boy error! Used simple non JQuery method. Now onto my real purpose which is calling Azure function from button click. Will return to the original problem re JQuery format once got Azure call working, just trying to prove some functionality which we need. Thank you for your and Oliver's help.
Thanks Oliver, yes I can do that no problem, I didn't realize this was what you meant by clear cache, I was trying to use "portal_path/_services/about". Interestingly when one of my colleagues with admin rights navigates to this URL we only see a page with Portals "some guid" and nothing else
Another way to clear the cache is using the "Sync Configuration" option from Portal Studio. Go to make.powerapps.com --> apps --> select the Portal App and click Edit
This will open the Portal Studio, you should be able to see a button for "Sync Config" there.
Hi Oliver
Thanks for the reply. Yes the change is under the Localized/Content Web Page/Advanced/Custom Javascript. However, the cache hasn't been cleared as I don't have admin rights. Once this is sorted I will let you know the outcome.
As per Oliver's comment, and also make sure that the script has refreshed in the cache (you need to reset the portal cache after each JS update etc). I think what you have should work, but...
Possibly try dropping the "window." and leave just alert(). You could also try the other method for the onclick (and also the non Jquery with just an onclick in the input tag to get something working)
$("#inputid").on("click", function(){
alert("Was clicked.");
});
Hi @paulsnolan, in Power Apps Portals, we have two Web Pages, a parent/root Web page, and a localized/content Web Page.
Can you confirm if your JS code is under the Localized/Content Web Page? That's where it should be placed.
Also, have you cleared the cache?
Lucas001
60
Super User 2025 Season 1
Fubar
55
Super User 2025 Season 1
surya narayanan
35