Skip to content
Extracting File Names with DocIntel

Extracting File Names with DocIntel

April 17, 2026·jcmings
jcmings

This article is about how to find the names of the files you’re processing in ServiceNow Document Intelligence, or DocIntel. I was unable to find this information on Google, on the docs, or from a human.

This article has to do with the Now Assist Extract information from document skill and should not be confused with the legacy, in-the-act-of-being-deprecated, Document Intelligence.

Before anything else, how DocIntel works

Ok - so I’m assuming you’ve already set up your use case in Document Intelligence. If you haven’t, go to Now Assist Admin > Skills, navigate to Platform on the left-hand sidebar, and search for doc. You should see a skill called Extract information from documents:

Extract information from documents skill

Long story short, because I don’t know all of the details: when your use case eventually runs, and your PDF is uploaded, it gets converted to an image file for the analysis. Why, I do not know, but that’s the reality of it. Your image then gets scraped based on your setup of the skill and the data is written to the output table you defined.

If you, like me, need to access the file name for that PDF you uploaded, this is the guide for you. The file names are not written to the Generative AI Logs [sys_generative_ai_logs] table or the Document Task [sys_di_task] tables as you might expect, but instead to the (Document) Images [sys_di_image] table.

As mentioned, they are converted to .jpegs! There is also an appendation of _1 at the end of the file name (it may increase to _2 and so on, if you have multiple files). But everyting ahead of that will be the name of your file. Here’s an example:

Input: Hello World.pdf
Output: Hello World_1.jpeg

You can use regex or some other method to get the file name from that string.

But how do you find your specific file?

Well, I’ve got a flow for that! Assuming your flow already has the DocIntel - Create a Document Task and/or DocIntel - Process a Document Task actions in it, you just need to do a few more steps:

  1. Set up a Look Up Document Task Record. This record should point to the Document Task [sys_di_task] table with the condition of Sys ID is (pill variable to DocIntel - Create a Document Task > Task ID).

  2. Ensure you have a Wait For condition set up that says Document Task Status is Done. You can literally point this to the flow action above (#1, right above these lines), and just set the Condition to Status is Done.

  3. Set up a custom flow action that passes in the Document Task Sys ID and outputs the Document Name as a string.

Here’s whatcha need for that flow action

We’re going to build a really simple flow action. To get started, in Workflow Studio, click the + button along the top tab bar, and select Action. Name it whatever you want. I’d recommend Get Document Name from Document Task.

Flow action setup

For the Inputs, we just need the Task Sys ID. This is a string that we’re receiving from the Look Up action mentioned above.

Next, add a Script step. Just one input variable, which again is going to be that sys_id. Using the data pills, set the value to the input we just defined.

Script step input variable

Our Script will do a simple lookup:

(function execute(inputs, outputs) {

    var imageTable = new GlideRecord('sys_di_image');
    imageTable.addEncodedQuery('task.sys_id=' + inputs.task_sys_id);
    imageTable.query();
    if (imageTable.next()) {
        outputs.file_name = imageTable.attachment.getDisplayValue();
    }

})(inputs, outputs);

This just GlideRecords into the (Document) Images [sys_di_image] table, passing through the sys_id from the task, and outputting the display name of the Document field (which is named attachment in the table).

Scroll down and don’t forget to add an output variable.

Script step output variable

And then make sure to set up an Output for the whole Action. Mine’s called File name and it points to step > Script step > File name.

Action output

Save, test, and publish! If you need a test value, copy the sys_id from a record on Document Task [sys_di_task]. (You should recognize the display name for one of the tasks you set up earlier, assuming you’ve performed at least one test. If you haven’t, go back into the Doc Intel skill and upload something.)

It’s important that you set up the Wait For Document Task Condition step (#2 in the But how do you find your specific file? section above). If you don’t, your next flow action (which actually does the file name retrieval) may come back empty.

With that set up, you should be all set to grab the document title. Note that this may create a cross-scope privilege from your scope into some of the sys_di_... tables. If you run into errors, make sure that cross-scope privilege is approved and the application access on the sys_di_... tables is set to Can read.

Cheers!