how to print multirow value in ui page servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 09:26 PM
hello everyone, how can I print multirow data on the ui page, so that when pressing the Print BAST button, multirow data appears on the servicenow ui page.
which I have successfully configured are
1. create a ui action / button with the name print bast
2. when the print bast button is clicked, it displays the ritm variables data but not the multirow variable set data.
3. the name of the multirow variable set is data_asset
<?xml version="1.0" encoding="UTF-8"?>
<j:jelly xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null" trim="false">
<!--
In this 'evaluate' tag we use JavaScript to query the change_request table for current sys_id.
-->
<div style="height: 20px" class="print_hide text-align-right">
<button type="submit" onclick="javascript:window.print();">
<img src="images/printer.gifx"></img>
<span>Click to Print</span>
</button>
</div>
<style type="text/css">
table, td {
border-color:#000;
border-style:solid;
}
table {
border-collapse:collapse;
border-spacing:0;
border-width:0 0 1px 1px;
margin-top:14px;
}
td {
border-width:1px 1px 0 0;
margin:0;
padding:4px;
vertical-align:Bottom;
}
th {
border:1px solid black ;
padding:4px;
}
table.borderless, table.borderless td {
border:0px;
border-style:none;
}
table.borderAroundMe {
border:1px;
border-style:solid;
}
td.header {
background-color:#8DB4E2;
font-weight:bold;
}
.center {
text-align:center;
}
@media print {
html, body {
margin:0;
padding:0;
}
br.page-break {
display:block;
page-break-before:always;
}
table {
page-break-after:auto;
}
tr {
page-break-inside:avoid;
page-break-after:auto
}
td {
page-break-inside:avoid;
page-break-after:auto
}
thead {
display:table-header-group
}
thead tr{
background: sandybrown;
}
tfoot {
display:table-footer-group
}
img {
display:block;
}
div.printPage {
position:relative;
page-break-inside:avoid;
page-break-after:auto;
height:100%;
width:100%;
}
table.footer {
position:absolute;
bottom:0;
}
}
@page{
margin:80px auto;
}
</style>
<g:evaluate var="jvar_gr" object="true">
<!--query untuk item Permintaan perangkat TI -->
var numbers=1;
var req = new GlideRecord('sc_req_item');
req.get('${sysparm_id}');
req.addQuery('cat_item', '=', '8b4e5beedb5080d0a4fd12371b9619be');
req.query();
var data = JSON.parse(${jvar_gr.getValue('params')})
</g:evaluate>
<div>
<table class="borderless" width="100%">
<tr>
<td><img src="btpn-syariah.png" height="80px" class="chart"></img></td>
<td align="middle" style="vertical-align: middle;"><h3 style="margin:auto; ">
<b>BAST
${HTML:req.cat_item.getDisplayValue()}
</b></h3></td>
<td style="vertical-align: middle;">
<div style="float:right;">
<table style="border-style:inset; border-width:medium;">
<tr>
<td>
<font size="4">
<b>RITM #: ${HTML:req.number}</b>
</font>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<table class='borderless' style="border-style:solid; border-width:1px;" width="100%" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="10%">
<b>Nama:</b>
</td>
<td width="40%">
<b>${HTML:req.request.requested_for.first_name.getDisplayValue()}
${HTML:req.request.requested_for.last_name.getDisplayValue()}</b>
</td>
<td width="10%">
<b>Jabatan:</b>
</td>
<td width="40%">
<b>${HTML:req.variables.jabatan}</b>
</td>
</tr>
<tr>
<td width="10%">
<b>NIK:</b>
</td>
<td width="40%">${HTML: req.variables.nik}</td>
<td width="10%">
<b>Tanggal Request:</b>
</td>
<!--<td width="40%">${HTML: req.sys_created_on.toString().substring(0,10)}</td>-->
<td width="40%">${HTML: req.sys_created_on.getDisplayValue()}</td>
</tr>
<tr>
<td width="10%">
<b>Departement:</b>
</td>
<td width="40%">${HTML:req.request.requested_for.department.name}</td>
<td width="10%">
<b>Request:</b>
</td>
<td width="40%">${HTML:req.request.number}</td>
</tr>
</table>
<br />
<b>Item</b>
<table style="border:1px solid black !important;border-collapse:collapse !important;" width="100%" align="center" cellspacing="0" cellpadding="0">
<thead>
<!-- <j:if test="${gr4_1.next()}"> -->
<tr style="background: sandybrown;">
<th>No</th>
<th>Service MOnitor</th>
<th>Display Name</th>
<th>Serial Number</th>
<th>IMEI</th>
<th>Asset Critical</th>
<th>Nomer PO</th>
</tr>
<!-- </j:if> -->
</thead>
<tbody>
<j:while test="${jvar_gr.next()}">
<tr>
<td align="center">${(numbers++).toString()} </td>
<td>${data}</td>
<td>${req.display_name.getDisplayValue()}</td>
<td>${req.serial_number.getDisplayValue()}</td>
<td>${req.u_imei1.getDisplayValue()}</td>
<td>${req.u_asset_critical.getDisplayValue()}</td>
<td>${req.po_number.getDisplayValue()}</td>
</tr>
</j:while>
</tbody>
</table>
<br />
<table class="borderless" width="100%" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" align="left">
<b>Deskripsi:</b>
</td>
</tr>
<tr border="solid 1px">
<td width="100%" align="left">
<b>${HTML:gr4.description}</b>
</td>
</tr>
</table>
<br />
<table class="borderless footer" width="100%" align="center" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left">Requestor <br/><br/></td>
<td width="50%" align="right">IT Asset <br/><br/></td>
</tr>
<tr>
<td width="50%" align="left"></td>
<td width="50%" align="right"></td>
</tr>
<j:while test="${ticket.next()}">
<tr>
<td width="50%" align="left"> ${HTML:ticketing} <br/>${HTML: ticket.closed_at.getDisplayValue()}</td>
</tr>
</j:while>
<tr>
<td width="50%" align="left">___________________________________</td>
<td width="50%" align="right">___________________________________</td>
</tr>
</table>
</div>
</j:jelly>
please help and direction because I am still confused about the logic of the multirow itself 😁
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:41 PM
you can parse and store an object in g:evaluate tag
Then you can iterate that.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:01 AM
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html lang="en" class="ltr" dir="ltr">
<head>
</head>
<body>
<div>
<div class="left-container" style="float:left;width:12%">
<g2:evaluate jelly="true" object="true" var="jvar_jsonObj">
var incs = [];
var gr = new GlideRecord('sc_req_item');
gr.get('${sysparm_id}');
gr.query();
var myCount = gr.getRowCount();
while (gr.next())
{
var obj = {};
<!-- var obj2 = JSON.parse(gr.getDisplayValue("variables.data_aset"));// multirow -->
obj.task = gr.getUniqueValue();
obj.caller = gr.getDisplayValue("number");
obj.request = gr.getDisplayValue("request");
obj.mRow = gr.getDisplayValue("variables.jabatan");
obj.mRow2 = gr.getDisplayValue("variables.data_aset.sn_perangkat");
incs.push(obj);
}
incs;
</g2:evaluate>
<div>
<j2:forEach items="$[jvar_jsonObj]" var="jvar_json">
<div id="incident-$[jvar_json.task]-$[jvar_json.caller]-content" class="my-incident-content">
<p> Results $[jvar_json.task]-$[jvar_json.caller]-$[jvar_json.request]-$[jvar_json.mRow] -$[jvar_json.mRow2] </p>
</div>
</j2:forEach>
</div>
</div>
</div>
</body>
</html>
</j:jelly>
I've changed my script but with this method I still can't display data from the variable set multirow, for the multirow name is data_assets, and the results I want to display are
variables.data_asset.sn_device but this does not appear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 01:48 AM
did you debug by adding gs.info() in g:evaluate?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 02:22 AM
yes when i put gs.info(); the result is empty
can u help guide me I've been stuck here for a few days