How to save a QR Code to an image field via a script

Community Alums
Not applicable

Hi All,

I have implemented the project from the ServiceNow share at the below link and am able to create a QR code that behaves as I need it to:

https://developer.servicenow.com/app.do#!/share/contents/5194766_task_qr_code?v=1&t=PRODUCT_DETAILS

However, my full requirement is to create a QR code upon creation of a record and save that code to an image field on said record automatically.

The above project utilises a UI action to trigger the creation and a UI page to display the resulting QR Code, however, despite some extensive digging, I have been unable to find a way to find a way to create the image and save it to an image field automatically, for instance, using a Business Rule .

If anyone could assist me and/or point me in the right direction, it would be much appreciated.

Many Thanks,

Jason

 

9 REPLIES 9

SaschaWildgrube
ServiceNow Employee
ServiceNow Employee

Hi there,

one option to do it is to create the QRCode raw data on the server and then convert it directly into html and then create a PDF based on html which would then be stored as an attachment to the record.

Check this out:

https://github.com/saschawildgrube/servicenow-devtools/blob/master/update/sys_script_include_ee4a4c0...

The DevTools app contains a truckload of reusable scripts and
features to support your app development.

Fork at will!

Hey Sascha, I have tried to run your code but getting a lot of errors such as:
"GetIntegerValue" not defined
"GetStringValue" not defined
"Clone" not defined

Please advise.

Sounds like you did not install DevTools.

Two options:

1. Install DevTools (recommended)

2. Add the mentioned functions manually - and then add more functions on which these functions depend on manually. This is quite same manual work and you won't benefit from DevTools updates and bugfixes. 

Balakrishna2
Tera Contributor

Any updates on this requirement?? facing exactly the same problem, able to generate the QR code but not able to save the image automatically.

Community Alums
Not applicable
Hi Balakrishna,
 
This was for an old project I was working on and I ended up doing this element in Service Portal, so was able to achieve my goal with a custom widget.
 
I called the UI script from the project mentioned above from the client controller and passed the data to the Server Script where I then saved the QR Code image to the attachment table using the GlideSysAttachment API and then to the desired record in an image field using the sys_id from the attachment record.