How to make the light weight glidelist query dynamic with javascript in dynamic block?

Amardeep2
Tera Contributor

I am trying to pass the query dynamically via javascript. Here is my code:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
    <script>
        loadJS();

        function loadJS() {
            alert('hello');
            var locationArray = '9898as9df9v9asd8f9a8sf'; // Modify this dynamically as needed
            //var UserLookUp = gel('featureListRoleOpenList');

            var anchor = document.querySelector("td.featureListRoleGroup a");

            if (anchor) {               
			   anchor.setAttribute("onclick", "mousePositionSave(event);reflistOpen( 'QUERY:active=true^sys_idINcd4ac21b1bc5a510ad8e43f0b24bcb4f', 'not', 'sys_user', '');");
            }
        }
    </script>

    <g:macro_invoke id="requesterID" name="requesterNm" macro="lightweight_glide_list2" control_name="QUERY:active=true" display-value="true" reference="sys_user" can_write="true" />
</j:jelly>

I was able to pass the query to glide  list with above code, however, once the pop up appears, when I select the user, nothing happens. Generally , once we select the record, the pop up disappears and the value can be seen added in the list box. However, it is not happening in my case? Any help would be appreciated. Thank you.

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Amardeep2 

check if these links help

Trouble setting a default value to lightweight_glide_list2 macro 

Reference qualifier in lightweight glide list 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Amardeep2
Tera Contributor

okay, I will check the links. thanks for the help, ankur.