- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2018 02:51 AM
I've created UI page to display record of incident table. But am not getting the values of state & short description fields.
Here is the code:
<tr>
<td> ${gr.number}</td>
<td> ${gr.caller_id.getDisplayValue()} </td>
<td> ${gr.category} </td>
<td> ${state.getDisplayValue()} </td>
<td> ${short_description.getDisplayValue()} </td>
</tr>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 08:17 AM
Ok, I had to mess around with it a bit, but this is working for me:
First 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">
Start Date:<g:ui_date name="start_date" id="start_date" table="incident" field='sys_created_on'/> <br/><br/>
End Date:<g:ui_date name="end_date" table="incident" field='sys_created_on'/>
<br/>
<br/>
<button onClick = "MyFunction()"> Ok </button>
<button onClick = "MyFunction2()"> Cancel </button>
</j:jelly>
Client script:
function MyFunction(){
var date1 = gel("start_date").value;
var date2 = gel("end_date").value;
var nums = '';
var gr = new GlideRecord('incident');
gr.addQuery('sys_created_on','>=',date1);
gr.addQuery('sys_created_on','<=',date2);
gr.query();
while(gr.next()){
nums += ',' + gr.getValue('number');
}
window.open("date_range_selected_incident.do?sysparm_nums="+nums);
}
function MyFunction2(){
window.open("Date_Range_selecting_incident",target="_self");
}
Second 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">
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 50%;
}
tr, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
<body>
<table>
<tr>
<th>Incident Number </th>
<<th> Caller </th>
<th> Opened </th>
<th> Opened by </th>
<th> Assigned to</th>
<th> Priority</th>
<th> State </th>
<th> Short Description </th>
</tr>
<g2:evaluate var="jvar_incident" jelly="true" object="true">
var inc = new GlideRecord('incident');
inc.addQuery('number','IN',jelly.sysparm_nums);
inc.query();
</g2:evaluate>
<j2:while test="$[inc.next()]">
<tr>
<j2:set var="jvar_num" value="$[inc.number]"/>
<j2:set var="jvar_caller" value="$[inc.caller_id.getDisplayValue()]"/>
<j2:set var="jvar_opened" value="$[inc.opened_at.getDisplayValue()]"/>
<j2:set var="jvar_openedby" value="$[inc.opened_by.getDisplayValue()]"/>
<j2:set var="jvar_assigned" value="$[inc.assigned_to.getDisplayValue()]"/>
<j2:set var="jvar_priority" value="$[inc.priority.getDisplayValue()]"/>
<j2:set var="jvar_state" value="$[inc.state.getDisplayValue()]"/>
<j2:set var="jvar_short" value="$[inc.short_description]"/>
<td> $[jvar_num]</td>
<td> $[jvar_caller] </td>
<td> $[jvar_opened] </td>
<td> $[jvar_openedby] </td>
<td> $[jvar_assigned] </td>
<td> $[jvar_priority]</td>
<td> $[jvar_state]</td>
<td> $[jvar_short]</td>
</tr>
</j2:while>
</table>
</body>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 01:03 AM
Hi Haritha,
Is this the only code or part of it.
Following example shows complete code and you can modify it as per your need:
it will print in tabular format the records from incident which are active=true
<g:evaluate var="jvar_gr" object="true">
var gr = new GlideRecord("incident");
gr.addQuery("active", true);
gr.query();
gr;
</g:evaluate>
<j:while test="${jvar_gr.next()}">
<tr>
<td> ${jvar_gr.number}</td>
<td> ${jvar_gr.caller_id.getDisplayValue()} </td>
<td> ${jvar_gr.category} </td>
<td> ${jvar_gr.priority} </td>
<td> ${jvar_gr.short_description} </td>
</tr>
</j:while>
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 06:07 AM
Thank you.
I've created two UI pages.
->In the 1 st page create a date range selection UI, an ok button and a cancel button.
On clicking the ok button it should take the user to the next UI page.
-> In the 2 nd UI page, all the incidents created between the date range selected in 1 st
page should be shown in a tabular form-
Incident Number
Caller
Opened
Opened By
Assigned to
Priority
But am not getting the values.
Here is the code:
The 1st UI Page Code:
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">
Start Date:<g:ui_date name="start_date" id="start_date" table="incident" field='sys_created_on'/> <br/><br/>
End Date:<g:ui_date name="end_date" table="incident" field='sys_created_on'/>
<br/><br/>
<button OnClick = "MyFunction()"> Ok </button>
<button OnClick = "MyFunction2()"> Cancel </button>
</j:jelly>
Client Script:
function MyFunction(){
var date1 = gel("start_date").value;
var date2 = gel("end_date").value;
var createdon = "sys_created_onBETWEEN"+date1+"@"+date2;
var gr = new GlideRecord('incident');
gr.addEncodedQuery(createdon);
gr.query();
while(gr.next())
{
gr.getValue('number');
}
window.open("date_range_selected_incident.do?sysparm_inc_id="+number);
}
function MyFunction2(){
window.open("Date_Range_selecting_incident",target="_self");
}
The 2nd UI Page Code:
<?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 {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 50%;
}
tr, td {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
</style>
<g:evaluate jelly='true'>
var gr = new GlideRecord("incident");
gr.get(jelly.sysparm_inc_id);
</g:evaluate>
<body>
<table>
<tr><td>Incident Number </td>
<td> Caller </td>
<td> Opened </td>
<td> Opened by </td>
<td> Assigned to</td>
<td> Priority</td></tr>
<tr><td> ${gr.number}</td>
<td> ${gr.caller_id.getDisplayValue()} </td>
<td> ${gr.opened_at} </td>
<td> ${gr.opened_by.getDisplayValue()} </td>
<td> ${gr.assigned_to.getDisplayValue()} </td>
<td> ${gr.priority}</td>
</tr>
</table>
</body>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 06:11 AM
If the code is as displayed in your original post, then you're missing the gliderecord variable (${state.getDisplayValue()} vs. ${gr.state.getDisplayValue()} ).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2018 06:14 AM
I've another problem.
can you please help me.