Friday 11 December 2020

APEX 20.2 - On Submit JS Syntax error, unrecognized expression: #PX_{BUTTON_NAME}_DISPLAY

 

Submit page and button JS error when hidden page item name contains $ sign

Page submit stopped working and you get some strange JavaScript error?


This is another post touching on naming standards
 
I was asked for an advice by a client that stumbled on this issue and I wanted to share it here. Scenario is simple let's say you create a blank page like below.
 

So all we have on the page is simple region with one submit page button and one hidden item.

If you run the page and click the button your page would submit and page would be re rendered. Perfect that is easy enough to do and expected behavior.
 
What if we as a user decide to go with unconventional naming standard and named this hidden item PX_NEW$TEST. Notice $ sign in there. 


Perfect, save and run the page click on the the same button again. Nice JS warning message alert is there with this in console log - Syntax error, unrecognized expression. 


But wait how do we debug this? Imagine if this was a huge page with over 30 items on it. Where do you start?!!! There is nothing in the page called NEW$TEST_DISPLAY on my page not even on the application level..... 
 
I am hoping you will not lose time on this and that somewhere down the line it will ring the bell that probably naming page items with special signs is probably not a good idea anyway.
 
For fun of it, try calling your page item something along NEW#TEST and see what APEX will actually save as an item name.  

We could say it would be nice to see APEX handling this situation too but hey having good naming standard in place would help here too. :)

To be clear this may not have been just APEX 20.2 error but potentially can happen in earlier version too so add this odd use case to your memory box somewhere.


Happy APEXing,
Lino

2 comments: