File API (GetFileFactory, EntityFileLocator) Not Working in Process ScriptTask - Compilation Errors
Hello Team,
We are facing an issue while trying to use the File API inside a Process ScriptTask and would like your clarification.
According to the Creatio Academy documentation (File API overview), it is possible to work with files using the following approach:
IFileFactory fileFactory = UserConnection.GetFileFactory(); var fileLocator = new EntityFileLocator("SysFile", recordId); IFile file = fileFactory.Get(fileLocator);
However, when implementing this logic inside a ScriptTask of a business process, the code does not compile, and we receive the following errors:
'UserConnection' does not contain a definition for 'GetFileFactory'The type or namespace name 'EntityFileLocator' does not exist in the namespace 'Terrasoft.File.Abstractions'
This suggests that:
GetFileFactory()is not available in Process ScriptTasksEntityFileLocatoris not accessible in the process execution context
Our goal is to:
- Read the content of an existing file (e.g. from SysFile or a custom *File entity)
Could you please confirm:
- Whether the File API (
IFileFactory,EntityFileLocator,IFile) is officially supported inside Process ScriptTasks - If not supported, what is the recommended and supported way to read an existing file and reuse its content inside a process
Thank you in advance for your support and clarification.
Like
Have you tried adding the Terrasoft.File namespace to the process usings?
Hello,
Please check the documentation regarding File API.
According to it EntityFileLocator is located in the Terrasoft.File namespace. Same goes for UserConnection.GetFileFactory and IFileFactory.Get (see FileFactoryUtils).
So, all you need to do is to add this namespace to your process (Methods -> Usings):