How to get the filename of the document into the document definition field?

Question

How to get the filename of the document into the document definition field?

 

Answer

The inbuilt way of getting the image source into the document definition field is using the service field with the ImageSource data source. The result of the hot folder import would look like this:

\\FC12\Import\Invoice02.tif

However, this way is not always useful when we need just the name of the file, not the full path.

In such a case, we can use a regular text field instead of a service field and populate the value using the script rule with the following code:

Context.Field("FieldAlias").Text = Context.Document.Pages[0].ImageSourceFileSubPath;

The produced result will look like this:

Invoice02.tif

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.