Skip to main content
Question

How I can add JavaScript in window onload for Acumatica customization screen.

  • January 30, 2026
  • 3 replies
  • 29 views

    I have below script that I can be able to add at my screen. But Same script I am not able to add in Existing screen as customization.

I want to add this script on page load of Custom screen. I have try with Acumatica customization editor but when I have added this script inside asp control ...while generate script it has gone….please help

<script type="text/javascript">
    window.onload = function () {
    setTimeout(function () {
        const el = document.querySelector(
            "#ctl00_phG_tab_t18_EWQCCstPXTab35_t3_QCAttributesDetailsGrid_at_tlb_ul li:first-child"
        );

        if (el) {
            el.addEventListener("click", function (e) {
                e.preventDefault(); // optional
                console.log("First li clicked");
                var ds = px_alls['ds'];
                ds.executeCallback('EWQCRefreshAnnotations');
            });
        }
    }, 500);
     };
 </script>

3 replies

harutyungevorgyan
Jr Varsity I
Forum|alt.badge.img+3

Hello ​@bpatidar72 ,
 

To prevent your script from disappearing when you save in the Customization Editor, use the PXJavaScript control. This is the standard way to handle scripts in the Acumatica Classic UI.

Also, keep in mind that using hardcoded ASP.NET IDs (like ctl00_phG_tab..) can be risky as they may change. You might want to use ControlD properties or CSS classes to find your elements more reliably. Check out this ​@Yuriy Zaletskyy ‘s blog post for more details: Using PXJavaScript in Acumatica.


shushanna34
Freshman II
Forum|alt.badge.img
  • Freshman II
  • January 30, 2026

Hi ​@bpatidar72 for adding the JS in you customization please do the following steps.

  • Go to the Customization Package, open the screen where you want the JS to work
  • Add Control Jasa Script 
  • Put you code in Function something like this 
     

    function test() {
        window.onload = function() {
            setTimeout(function() {
                const el = document.querySelector(
                    "#ctl00_phG_tab_t18_EWQCCstPXTab35_t3_QCAttributesDetailsGrid_at_tlb_ul li:first-child"
                );

                if (el) {
                    el.addEventListener("click", function(e) {
                        e.preventDefault(); // optional
                        console.log("First li clicked");
                        var ds = px_alls['ds'];
                        ds.executeCallback('EWQCRefreshAnnotations');
                    });
                }
            }, 500);
        };
    }

     

  • and then call test() function in Screen’s forms Client Event, either Data Source’s Client Events, or Form’s it depends on working requirements.

This should work, in case of anything ready to help. :) 


Regards,
Shushanna


zherring
Freshman I
  • Freshman I
  • January 30, 2026

Someone correct me if I am wrong but I believe you can also put this code into the Page_Load method within the aspx.cs file although you might have to refactor the script some to fit into the .cs style of file.