Download a Html Encoded QR code

abhi56
Tera Contributor

Hi i have created a Qr code using ui script and ui macro and have displayed it in the portal using widget ,now it is displaying i hvae added one button download ,my requirement is to download the qr code on clicking the button

Main point is qr code is not getting stored anywhere ,and we are unable to convert it to base 64 

Need solution for downloading this dynamic qr code 

HTML

<div>
<h3>
Details of Postage Label:
</h3>
<!-- your widget template -->
<div ng-if="data.show" id="qrcode"></div>
<br/>
<a target="_new" href="/{{data.f.table}}.do?PDF&sys_id={{data.sys_id}}&sysparm_view={{data.f.view}}" tabindex="-1">${Download}</a>

<script src=
"https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js">
</script>
</div>

 

CLIENT SCRIPT

api.controller=function($scope,$timeout) {
/* widget controller */
var c = this;
//$j('#qrcode').qrcode('hello');
$scope.$watch('$viewContentLoaded', function() {
$timeout(function() {
new QRCode(document.getElementById("qrcode"), document.URL);
}, 2000);
});



};

 

SERVER SCRIPT

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */

data.show = $sp.getParameter('sys_id') == -1 ? false : true;

1 REPLY 1

ben_hollifield
Tera Guru

Hi abhi56 - I don't have an answer to your direct question. However, Yansa Labs offers a QR/Barcode Generator app that can expose QR Codes in any ServiceNow interface, and also allows downloading that QR Code. If you're still stuck, this could meet your requirement. The links below may be helpful. Feel free to reach out to me at ben@yansalabs.com with any questions!

 

https://docs.yansalabs.com/barcode-and-qr-code-generator

https://store.servicenow.com/sn_appstore_store.do#!/store/application/eb2b91341bd68490118b8774cc4bcb...