Reputation: 53
I want to retrieve an item from a SharePoint Online list (Office 365) and print it out in a form format. I have looked at a few ways which involve using power automate and third party tools which such as Muhimbi and Encodian to put the item's values into a HTML form template and convert and download the as a PDF. However this solution requires paying for the third party apps which is extremely expensive. Is there anyway that I can work around this. Are there any other methods of generating and printing the form with the values of the SharePoint list item ?
Upvotes: 2
Views: 1002
Reputation: 308
Oh wow. I have a ready made answer for this. Here is how I implemented a print function from within powerapps & flow. No extra addons or anything. Just a printer with email and a simple understanding of HTML and powerapps.
Here is the article to get the printer to print: https://powerusers.microsoft.com/t5/Building-Power-Apps/Automatic-Printing-using-Flow-and-a-copier-this-is-a-workaround/m-p/556375
Setting up the HTML is the hardest part. I did it easily by using Notepad ++ in HTML language mode. Then plugging in the variables after copy pasting to powerapps collect. Here is one of the snips of my code:
UpdateContext({PrintStatus:1});'ProcessWorkOrder-2'.Run("<!DOCTYPE html>
<html>
<head>
<title>TicketNumber."
&Text(dcvTicketID)&"
."& Text(dcvCustomerName)&"
</title>
<style>
div.ltr {
background-color: white;
}
#head {
display: flex;
justify-content: space-between;
padding: 5%;
}
#head div {
width: 50%;
}
.head {
display: flex;
background-color: white;
}
.head > div {
padding: 20px;
}
div.border {
border: 1px solid #333;
text-align: right;
}
table.cdata {
position: relative;
left: 0.25in;
top: 0.25in;
}
table.cdata1 {
position: relative;
margin-left: 5%;
margin-right: 5%;
top: 0.25in;
width: 90%;
}
table,
td, th {
border: 1px solid #333;
}
thead,
tfoot {
background-color: #99ebff;
color: black;
}
.bold {
font-size: 25px;
}
img {
border: 2px;
}
p {
white-space:pre-wrap;
}
</style>
</head>
<body>
<br><br>
<div class='ltr'>
<div >
<div>
<table class='cdata1'>
<thead>
<tr><th class='bold' colspan='2'><strong>Duplicate Print Job</strong></th></tr>
</thead>
</table>
</div>
</div>
<br><br>
<div >
<div>
<table class='cdata1'>
<thead>
<tr><th class='bold' colspan='2'><strong>Ticket Information:</strong></th></tr>
</thead>
<tr><td>Ticket ID: </td><td> "&Text(dcvTicketID)&"</td></tr>
<tr><td>Chargeable Call: </td><td> "&If(tgIsChargeableCall.Value=true,"Yes, This is a chargeable call","No")&"</td></tr>
<tr><td>Has Been Invoiced: </td><td> "&If(tgBeenInvoiced.Value=true,"Yes,This has been invoiced","No")&"</td></tr>
<tr><td>Invoice Number: </td><td> "&Text(dcvInvoiceNumber)&"</td></tr>
<tr><td>Customer P.O. Number: </td><td> "&Text(DataCardValue38)&"</td></tr>
<tr><td>Ticket Status: </td><td> "&Text(ddStatus.Selected.Value)&"</td></tr>
<tr><td>Call Type: </td><td> "&dcvCallType.Selected.Value&"</td></tr>
<tr><td>Date Completed: </td><td> "&Text(dcvDateClosed)&"</td></tr>
<tr><td>Closed By: </td><td> "&Text(dcvClosedBy)&"</td></tr>
</table>
</div>
</div>
<br><br>
<div >
<div>
<table class='cdata1'>
<thead>
<tr><th class='bold' colspan='2'><strong>Customer Information:</strong></th></tr>
</thead>
<tr><td>Customer Name: </td><td> "&Text(dcvCustomerName)&"</td></tr>
<tr><td>Office Branch: </td><td> "&Text(dcvBranchName)&"</td></tr>
<tr><td>Location: </td><td> "&Text(dcvLocationName)&"</td></tr>
<tr><td>Make: </td><td> "&Text(dcvMake)&"</td></tr>
<tr><td>Model: </td><td> "&Text(dcvModel)&"</td></tr>
<tr><td>Serial Number: </td><td> "&Text(dcvSerialNumber)&"</td></tr>
<tr><td>Total Counter: </td><td> "&Text(dcvTotalCounter,"[$-en-US]#,###")&"</td></tr>
<tr><td>Black Counter: </td><td> "&Text(dcvBWCounter,"[$-en-US]#,###")&"</td></tr>
</table>
</div>
</div>
<br><br>
<div class='problem'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold'><strong>Problem Description:</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>"&dcvProblem.Text&"</p>
</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<div class='solution'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold'><strong>Solution:</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>"&dcvRichText.HtmlText&"</p>
</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<div class='visits'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold' colspan='4'>Visits:</th>
</tr>
<tr><th>Date</th><th>Time In</th><th>Time Out</th><th>Total</th></tr></thead>
<tbody>"& Concat(ItemGallery_8.AllItems, "<tr><td>"& Date &"</td><td>" & StartTime & "</td><td>" &EndTime&"</td><td>"&Value(Total)&"</td></tr>") &"</tbody><tfoot><tr><td class='bold' colspan='3'><strong>Total Time On-Site:</strong></td><td><strong>"& Sum(ItemGallery_8.AllItems, Total) &"</strong></td></tr></tfoot></table>
</div>
<br><br>
<div class='charges'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold' colspan='5'><strong>Chargeable Items:</strong></th>
</tr>
<tr><th>Item Type</th><th>Quantity</th><th>Description</th><th>Cost Per Item</th><th>Total</th></tr></thead>
<tbody>"& Concat(GalleryChargeableItems.AllItems, "<tr><td>"& ItemType &"</td><td>" & Quantity & "</td><td>" &ItemName&"</td><td>"&Text(Value(CostPerItem),"[$-en-US]$#,###.00")&"</td><td>"&Text(Value(SubTotalCost),"[$-en-US]$#,###.00")&"</td></tr>") &"</tbody>
<tfoot>
<tr>
<td class='bold' colspan='4'><strong>Total Cost:</strong></td>
<td><strong>" & Text(Sum(GalleryChargeableItems.AllItems, SubTotalCost ), "[$-en-US]$#,###.00")&"</strong></td>
</tr>
</tfoot>
</table>
</div>
<br><br>
<div class='charges'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold' colspan='2'><strong>Toners Delivered:</strong></th>
</tr>
<tr><th>Color</th><th>Quantity</th></tr></thead>
<tbody><tr><td>Black</td><td>" &Text(TK)&"</td></tr><tr><td>Cyan</td><td>"&Text(TC)&"</td></tr><tr><td>Magenta</td><td>"&Text(TM)&"</td></tr><tr><td>Yellow</td><td>"&Text(TY)&"</td></tr></tbody>
</table>
</div>
<br><br>
<div class='solution'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold'><strong>Notes About Toner:</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>"&dcvTonerNotes.Text&"</p>
</td>
</tr>
</tbody>
</table>
</div>
<br><br>
<div class='signature'>
<table class='cdata1'>
<thead>
<tr>
<th class='bold'><strong>Signed By: "& SignersName.Text &"</strong></th></tr></thead>
<tr>
<td><img src=" & JSON(Sinature.Image,JSONFormat.IgnoreBinaryData) & " width='450px'></td></tr></table></div></div><br><br><br><br></body></html>","Print_Job_"&Text(dcvTicketID)&"_WO_"&Text(Now(),"[$-en-US]mm.dd.yyyy_hh.mm.ss"))
Here is the flow to make the HTML doc and convert it to PDF:
Here is the flow to send the email with the attached pdf to the printer:
You could morph my solution to do your own thing. I would suggest automating converting your list to a csv using flow and then converting it to PDF. Most modern printers support Email, and will allow printing of attached PDFS. Kyocera is the brand I recommend using. But I think brother also allows this without having to buy extra stuff. There is also a python library out there that would let you send info to a printer.
Upvotes: 1