Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Shorten filename but retain extension for string variable

berlink0304
Level 2
Level 2

Hello,

Currently we are storing the filename of an attachment a user uploads into a variable (@strFileNm).  We then use that variable to build a URL to find the file in another location.  Once the file is found, it is stored in another variable (@docFile).

Later on, we use the filename variable to provide the filename to another application we interface with.  The problem I'm having is that application can only accept a string of 30 characters.

I need to be able to have the file name unchanged for when we are building the URL in the above steps.  After the file is retrieved and stored in the other variable, I need to change the value of the filename variable to a shortened value so it can go to our other application.

I need the file to retain the extension however.  These are .pdf files.  I'm trying to figure out how to shorten a filename if it's longer than 30 characters, but leave .pdf

Does this need to be done by nesting substrings in the Xpath expression?  substring-before(@strFileNm, '.pdf') would get the string before the extension, but if I cut down that string, will it later have the .pdf again at the end?  Or am I losing .pdf period with that method?

3 Replies
smacdonald2008
Level 10
Level 10

Are your working with Adaptive Forms, Adobe Document Services, are you using a custom process? Please provide more information on the products you are using?

berlink0304
Level 2
Level 2

I'm working with AEM 6.1 adaptive forms.  The OOTB attachment page is being used, and we hold that filename in our XML.  Eventually we take that xml value and give it to the strFileNm variable that we then use for a few steps in other processes we've built where we store and retrieve files from our server.

smacdonald2008
Level 10
Level 10

You can build a custom process step (using Java) to manipulate the name to fit your needs.