Passing QR Code from UI page to field of user form

gPadmavathi_04
Tera Contributor

Hi everyone,

 

Goal: I have created a QR code in the UI page, so I need to call that QR Code in the HTML field/ any field in the user form.

 

gPadmavathi_04_0-1709639332995.png

gPadmavathi_04_1-1709639378223.png

I need to call this QR Code in HTML field or image field of user form when the form is loading.

gPadmavathi_04_2-1709639726496.png

kindly help me with this...

 

Thank you,
padmavathi

3 REPLIES 3

gPadmavathi_04
Tera Contributor

@Ankur Bawiskar please help me on this req

 

UI Page;

HTML 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">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Add to Contact</title>
    <!-- Include the qrcode.js library -->
</script>
</head>
<script>
   function addToContact() {
    // User details (replace these with your actual user details)
    var userDetails = {
        firstname: 'John Doe',
        organization:'test',
        title:'first',
        email: 'john.doe@example.com',
        phone: '+1234567890'
    };
      var vCardData = generateVCard(userDetails);
             var blob = new Blob([vCardData], { type: 'text/vcard' });
            // var url = window.URL.createObjectURL(blob);
            var a = document.createElement('a');
            a.href = url;
            // a.download = 'contact.vcf';
            document.body.appendChild(a);
            a.click();
             document.body.removeChild(a);
        }
        function generateVCard(userDetails) {
            var vCard = "BEGIN:VCARD\n";
            vCard += "VERSION:3.0\n";
            vCard += "N:" + userDetails.firstname + "\n";
            vCard += "ORG:" + userDetails.organization + "\n";
            vCard += "TITLE:" + userDetails.title + "\n";
            vCard += "EMAIL;TYPE=INTERNET:" + userDetails.email + "\n";
            vCard += "TEL;TYPE=WORK,VOICE:" + userDetails.phone + "\n";
             vCard += "END:VCARD\n";    
 // Generate QR code
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        text: vCard,
        width: 128,
        height: 128
    });
}
</script>
<body onload="addToContact()">
<!--<img src="a" alt="Generated Image" />-->
    <div id="qrcode"></div>
</body>
</j:jelly>

Have you found a good solution? I would look for the same to show in the users profile (Especially in the mobile app)

ben_hollifield
Tera Guru

Hi gPadmavathi_04 - Unfortunately, I don't have a solution for adding your code to a form. However, Yansa Labs offers a solution for embedding QR codes on any form in ServiceNow. 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...