Solved

File Variable Type Confusion

  • 2 November 2021
  • 5 replies
  • 11 views

Userlevel 4
Badge +10

I'm trying to create a Component Workflow which has a File type variable as one of its starting values.  When I try to call this Component Workflow from another Workflow, I'm unable to pass it any File type variables. Instead, I'm only able to pass Text type variables to the File input. The documentation indicates that you should be able to pass a File variable to a component workflow: 

20541iAE3834359033A74D.png

 

 

Previously, I thought the File variable type was representing an actual file. However, the documentation says a File type variable is the following: "Path to a file. Use this variable type to attach files to email messages. A file path must start with the root folder and end with the file name. Example: /Draft/Contracts/ACME.docx"

 

I have two questions that are confusing me regarding File type variables.

  1. Why am I unable to supply a File type variable to a Component Workflow that expects a File type variable as a start variable? 
  2. If the File type variable is just a "Path to a file", can this value be retrieved for use in the Component Workflow?

 

Thank you for any help!

icon

Best answer by bsikes 31 March 2022, 23:13

View original

5 replies

Userlevel 4
Badge +10

Just an update here:


Was told that the developers said passing files from one workflow to a component workflow wasn't supported (other than passing an entire collection).  While trying to determine how to pull a specific file out of a collection, we determined that this actually was possible.


 


I used the following Query Json action to get the actual text reference to a specific file:



 


Signed Files: A collection of files (in this case returned from DocuSign)


TargetFileName: The name of the file I want to pull out of the collection


TargetFileJson: This will be the JSON reference to the file


 


After that action runs, I'm able to pass the TargetFileJson text variable to a component workflow's file input. That component workflow is then able to make use of the actual file from the parent workflow.


 


Also useful (and the point of my latest case with Nintex), you can use the following "Check if item exists in collection" action to get the index for a specific file out of a collection:



Signed Files: A collection of files (in this case returned from DocuSign)


TargetFileJson: Result of the Query Json action above


JSONFileFound: Boolean result of whether the file was found


TargetJSONIndex: The index in the collection where the desired file is


 


This could get be followed with the Get Item from Collection, using the Collection variable and the Index result above to pull the desired file out of a collection. 

Userlevel 4
Badge +12

@bsikes 


that's very helpful thanks.


 


For reference could you post as text in a reply the jsonpath expression?


That looks very handy and would like to avoid mistyping it.


 


Thanks

Userlevel 4
Badge +10

Sure thing:


$[?(@ =~ '/.*fileName":"DesiredFileName"/I')]

Badge +1

Thanks for sharing your solution @bsikes! Thinking outside the box on this one for sure.

Userlevel 4
Badge +10

@Gavin-Adams 


 


After some further testing, I found that attachments uploaded as part of a NWC Form are stored in the collection a bit differently than those returned from a third party (Or at least DocuSign). Seems like certain characters are percent encoded, which breaks the expression ('=' : %22, ':' = %3A)


 


This updated JSON Path expression seems to hit both types correctly:


​$[?(@ =~ '/.*fileName((?=":"TargetFileName)|(?=%22%3A%22TargetFileName))/I')]​

Reply