Markus Kraus
Kilo Sage

I was facing the requirement to add external documents to a record multiple times.

The existing solution was either based on a HTML field (unstructured) or we were forced to download the document (the latest version was actually on a sharepoint folder or something similar). Both of the solutions were not very nice, so i worked on a replacement.

I wanted to share this project as it might help a few people around here. The following screenshots might illustrate the feature:

  1. See the new document icon next to the OOTB-attachment icon. A click will open the "Add Virtual Attachment" Dialog:
    find_real_file.png
  2. Enter a URL and wait for the Attachment to be created on the record. It is even possible to generate a PDF that stores the URL in its binary data.
    find_real_file.png
  3. The attachment is now a real hyper link that will open the previously entered URL on click:
    find_real_file.png

 

If you are interested in using this, create a fork from my project:
https://github.com/kr4uzi/ServiceNow-Virtual-Attachments

Comments
payerle
Tera Contributor

@Markus Kraus I'm looking for something similar and wondering if you code could help. I have a request that Service Now will navigate to a given external URL and download and attach the PDF of the output of that page, back to the ticket itself.

 

I haven't looked through your code yet as I am still doing research, so just trying to understand functionality if yours does what I'm looking for.

 

In my example, we have a bit of code that can generate a shipping label. In some instances, we have to generate this as a PDF label, which from the shipping companies perspective, they simply provide us with a URL to the label. The downside is, the URL expires after 12 hours, so we would like to have a process where Service Now, after it generates the URL, to navigate to it, download the page as a PDF and then upload it back to the ticket.  The label itself expires after 6 months, but if someone doesn't retrieve the label in time, it can add extra cycles where we would need to recreate it. 

 

Thanks for any advice you can offer.

Markus Kraus
Kilo Sage

@payerle This application creates an actual attachment from the entered URL as well as another record (custom table) which is linked to the attachment. This additional record stores the URL.

So what you could do is create a Business Rule / Flow which downloads the file, create an attachment out of it and link it to the ticket. Afterwards delete the old "virtual" attachment.

I'd suggest you to try out the application in a Personal Developer Instance. Simply fork the git repo so that you can import the application using your own git key.

-Andrew-
Kilo Sage

Hi Markus,

 

This looks awesome, i've been trying to build something similar. 

 

I was also wondering if you could provide some assistance? I've forked the repo and imported into my dev instance but i'm having issues actually getting it to work. The macro doesn't appear on the form at all. 

 

Within the formatter, I've noticed no UI Macro exists, 

Info MessageUI Macro: x_376096_va_virtual_attachments does not exist

 

Wondering if there was anything i needed to do in order to get this setup perhaps?

 

Thanks so much!

Markus Kraus
Kilo Sage

@-Andrew- Can you tell me which ServiceNow version you are using and the Virtual Attachment Property Values?
Note: You might as well fetch the latest updates, as i have updated the code slightly.

-Andrew-
Kilo Sage

@Markus Kraus Sure! I'm on Utah.

Here's the properties:

Andrew_0-1682333333050.png

 

Markus Kraus
Kilo Sage

@-Andrew- Hm, but with global virtual attachments you shouldn't need to add the UI Formatter... Can you sync your fork and try to "Apply remote changes"? Unfortunately i cannot reproduce this error using a Utah Dev Instance + latest version of the virtual attachment repository...

Version history
Last update:
‎05-27-2023 03:48 AM
Updated by:
Contributors