How to retrieve data from custom table and display the data in the UI page

chandana14
Kilo Contributor

As i am a beginner in jelly scripting. I am facing issue to retrieve data from the custom table and to display that data in UI page. Can anyone help me with the script?

1 ACCEPTED SOLUTION

Hi Chandan,

You can do it in two ways:

in UI action you have to use setPreference and add the 

the variable we have used is (no_of_cases)  you can pass any value from the form to it as of now i have passed static 55 from ui action to ui page

var contactUIMacro = new GlideModal('sn_customerservice_Actives Cases with Same Contact', false, 'modal-lg');
	contactUIMacro.setTitle('Active cases with same contact');
	var noOfCases = '5';
	contactUIMacro.setPreference('no_of_cases', '55');  //The new variable which you need to pass to UI page
	contactUIMacro.render();

 

UI page:

you have to use the expression at the top and that variable you can use in the div tag.

<?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_num_case"
    expression="RP.getWindowProperties().get('no_of_cases')" />

	

	<div class="form-group">
		<p>There are currently ${jvar_num_case} active cases with the same contact.</p>
	</div>

</j:jelly>

 

 

 

Mark helpful and correct if it helps.

Thanks,

CB

View solution in original post

5 REPLIES 5

Chander Bhusha1
Tera Guru

Hi Chandana,

How are you using the UI page from custom table Is it by clicking of a UI action which will call the Dialog window and there you need the value of which you will pass through dialogwindow?

 

Can you provide more details on that?

Thansk,


CB

Hii CB,

Yes, I am calling a UI page by clicking the button in UI action as a glide dialog window. I need the values to be displayed in the main UI page which i have passed through glide dialog window.Can u plz help in this issue?

Hi Chandan,

You can do it in two ways:

in UI action you have to use setPreference and add the 

the variable we have used is (no_of_cases)  you can pass any value from the form to it as of now i have passed static 55 from ui action to ui page

var contactUIMacro = new GlideModal('sn_customerservice_Actives Cases with Same Contact', false, 'modal-lg');
	contactUIMacro.setTitle('Active cases with same contact');
	var noOfCases = '5';
	contactUIMacro.setPreference('no_of_cases', '55');  //The new variable which you need to pass to UI page
	contactUIMacro.render();

 

UI page:

you have to use the expression at the top and that variable you can use in the div tag.

<?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_num_case"
    expression="RP.getWindowProperties().get('no_of_cases')" />

	

	<div class="form-group">
		<p>There are currently ${jvar_num_case} active cases with the same contact.</p>
	</div>

</j:jelly>

 

 

 

Mark helpful and correct if it helps.

Thanks,

CB

Hi Chandana,

below is the sample code

You can enhance it as per your need

UI Action:

Onclick: showRecord()

Script:

function showRecord(){

	var sysId = g_form.getUniqueValue();
	var gDialog = new GlideDialogWindow('show_incident_details');
	gDialog.setSize('600','600');
	gDialog.setPreference('id', sysId);
	gDialog.setTitle('Show Incident');
	gDialog.render();


}

UI Page:

HTML:

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

	<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    text-align: left;
    padding: 8px;
}

tr:nth-child(even){background-color: #f2f2f2}

th {
    background-color: #4CAF50;
    color: white;
}
</style>
	
	<g:evaluate var = "jvar_id" expression="RP.getWindowProperties().get('id')"/>

	<h1>Incident Summary</h1>

	<g:evaluate var="jvar_inc" object="true">
		var inc = new GlideRecord('incident');
		inc.get('${jvar_id}');
		inc;
	</g:evaluate>

	<table border="1">
		<tr>
			<td>Number</td>
			<td>Assignment Group</td>
			<td>Priority</td>
			<td>Company</td>
			<td>Caller</td>
		</tr>
		<tr>
			<td id="number">$[inc.number]</td>
			<td id="assignment_group">$[inc.assignment_group.getDisplayValue()]</td>
			<td id="priority">$[inc.priority.getDisplayValue()]</td>
			<td id="company">$[inc.company.getDisplayValue()]</td>
			<td id="caller">$[inc.caller_id.getDisplayValue()]</td>
		</tr>
	</table>
</j:jelly>

Output:

find_real_file.png

Regards
Ankur

 

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