How can I get the current record's sys_id in a UI Page?

Arshdeep Singh
Tera Contributor

So i want a select box in my glideWindow UI Page where i have to display the users that are currently in a list collector of a record.
find_real_file.png

and i want to show these two users in a select box of UI Page here:

find_real_file.png

 

currently im using this script in my UI Page:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate jelly = "true">

var gr_inc = new GlideRecord('incident');
gr_inc.addQuery('sys_id', '2bdad2b61b5c23038e2520e6e4bcbf4');
gr_inc.query();
</g:evaluate>

<div>
<h2>Please select the users</h2>
<select>
<option>--NONE--</option>
<j:while test="${inc.next()}">
<option value="${inc.sys_id}">${inc.committee_list}</option>
</j:while>
</select>
</div>

</j:jelly>

 

By passing sys_id in 2bdad2b61b5c23038e2520e6e4bcbf4 addQuery its working but i need g_form.getUniqueValue() of the record or current.sys_id of the record so that it works dynamically for every record.

Any help would be greatly appreciated.

🙂

1 ACCEPTED SOLUTION

Hi,

This worked well for me

UI Action:

function showPage(){

	var gm = new GlideModal('sn_customerservice_show_my_ui_page');
	gm.setTitle('My Page');
	gm.setSize('600', '600');
	gm.setPreference('sysparm_caseID', g_form.getUniqueValue());
	gm.render();

}

UI Page:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

    <g:evaluate var="jvar_sysId" expression="RP.getWindowProperties().sysparm_caseID"/>

    <g:evaluate jelly="true" object="true">
        var gr_acp = new GlideRecord('sn_customerservice_case');
        gr_acp.addQuery('sys_id', jelly.jvar_sysId);
        gr_acp.query();
        gr_acp;
    </g:evaluate>

    <p>${jvar_sysId}</p>
    
    <div>
        <h2>Please select the users on behalf of which you would like to endorse the case</h2>
        <select>
            <option>--NONE--</option>
            <j:while test="${gr_acp.next()}">
                <option value="${gr_acp.sys_id}">${gr_acp.getDisplayValue()}</option>
            </j:while>
        </select>
    </div>

</j:jelly>

Output:

find_real_file.png

Regards
Ankur

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

View solution in original post

11 REPLIES 11

Hi Ankur,

 

I want to create a Dynamic URL, my code is below:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate var="jvar_it_connect_sc" object="true">
      var gr = new GlideRecord("sc_task");
      gr.addQuery('short_description', 'CNS team Firewall policy design task');
      gr.addQuery('sys_id', '815b9ca81bb72d10b3146538b04bcb00');
      gr.query();
      gr;
   </g:evaluate>    

   <j:while test="${jvar_it_connect_sc.next()}">
    </j:while>
    <a href="sc_task.do?sys_id=${jvar_it_connect_sc.getValue('request_item.u_vendor_ticket_number')}">link test</a>

</j:jelly>
 
In this code I want to use Dynamic sys id as current sc task sys id. This UI page is used in a catalog variable. How to get the current Sctasks sys id here?
 

Thanks Ankur..!

It was helpful