Hi,

is there any documentation on how to use the File param type in a business process? I wasn't able to find any.

I have a use case where i have to save a file as an attachment to an entity, starting from a base64 rappresentation of the file. I would like to accomplish this task with the least amount of coding. What i envisioned is a business process with a script task that converts the base64 to a File param. Then a process file shape that saves the File param. Sadly i'm dead in the water on how to implement this scenario because i have no idea on how to use File param type. I can't even understand what .Net/Terrasoft type it is. Do you have any suggestion?

Like 0

Like

1 comments

Hello,

Please specify if you have checked the available basic functionality meant for processing files within business processes - the "Process File" element? If so, could you describe why exactly does this option not work for you?

https://academy.creatio.com/docs/8.x/no-code-customization/bpm-tools/pr…

Show all comments

Hello;
In my 7.17 version i create a file repository override class and it work correctly
when I try to upgrade to 8,2,1 the FileService core class change and it create fileRepository object based on interface not class (ClassFactory.Get) and it run based method loadFile not override one.
Is it any solution to set the the default class for interface

Like 0

Like

5 comments

Hi,

Yes, starting from version 8.x, Creatio uses dependency injection (DI) more actively, including for services like IFileRepository, which is now resolved via ClassFactory.Get<IFileRepository>().

To override the default implementation, you can register your custom class as the default for the interface in the dependency container.
 

Solution: Register your class for the interface

You have to create your own AppEventListener and bind your class to the appropriate interface there.

 

public class UsrAppEventListener : AppEventListenerBase
{
	public override void OnAppStart(AppEventContext context) 	{
		base.OnAppStart(context);
		ClassFactory.Bind<IFileRepository, CustomFileRepository>(reuseType: ReuseType.Singleton);
    }
}

 

Where:

  • CustomFileRepository is your custom class that implements IFileRepository
  • ReuseType.Singleton (or None) depends on your usage

⚠️ Important: Ensure your class fully implements the IFileRepository interface.

This way, when FileService calls ClassFactory.Get<IFileRepository>(), it will receive your custom implementation.

TU Irina

Tomasz Branicki,

Hi Irina.
I finally manage to upgrate creatio properly so i can try your sollution.
write now i gut such error

Terrasoft.Core.InstanceActivationException
 HResult=0x80131600
 Message=Error creating an instance of the "Terrasoft.Configuration.IFileRepository" class
 Source=<Cannot evaluate the exception source>
 StackTrace:
<Cannot evaluate the exception stack trace>

 This exception was originally thrown at this call stack:
   [External Code]

Inner Exception 1:
ActivationException: Error activating IFileRepository
More than one matching bindings are available.
Matching bindings:
 1) binding from IFileRepository to FileRepository
 2) binding from IFileRepository to UsrFileRepository
Activation path:
 1) Request for IFileRepository

Suggestions:
 1) Ensure that you have defined a binding for IFileRepository only once.

My class is describe like that

    [Terrasoft.Core.Factories.Override]
   public class UsrFileRepository : FileRepository.

can you give me a hand :)

regards
Tomek

Iryna Oriyenko,

Hi Irina.
I finally manage to upgrate creatio properly so i can try your sollution.
write now i gut such error

Terrasoft.Core.InstanceActivationException
 HResult=0x80131600
 Message=Error creating an instance of the "Terrasoft.Configuration.IFileRepository" class
 Source=<Cannot evaluate the exception source>
 StackTrace:
<Cannot evaluate the exception stack trace>

 This exception was originally thrown at this call stack:
   [External Code]

Inner Exception 1:
ActivationException: Error activating IFileRepository
More than one matching bindings are available.
Matching bindings:
 1) binding from IFileRepository to FileRepository
 2) binding from IFileRepository to UsrFileRepository
Activation path:
 1) Request for IFileRepository

Suggestions:
 1) Ensure that you have defined a binding for IFileRepository only once.

My class is describe like that

    [Terrasoft.Core.Factories.Override]
   public class UsrFileRepository : FileRepository.

can you give me a hand :)

regards
Tomek

Iryna Oriyenko,

Hi Iryna;
I find solution
I used rebind except bind.
thank you for help

 

regards Tomek

Show all comments

Hi Community,

 

I have a question regarding customization file storage in Creatio. Is it possible to save files directly in the file system instead of the database (default)? 

I came across documentation on "Implementing a custom file storage," but I'm unsure whether these customizations affect the location where files are stored, or if they only modify the file metadata.

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

 

Additionally, is it possible to customize the format in which the file is saved? 

By default, files are saved as BLOBs (In Database). However, if we want to store files in the same format but directly in the file system rather than as BLOBs, would that be possible in Creatio?

Like 0

Like

1 comments

Hello, 

The "Implementing a custom file storage" documentation you referenced utlines how to achieve this, and it does indeed allow you to change the location where files are stored. 

 

The process involves implementing a custom file storage system using file management API. Specifically, you can:

 

This interface defines how file content is stored and retrieved. By creating a custom class that implements this interface, you can direct to save files to a file system instead of the database. For example, you could write a class that saves files to a specified directory on the server’s file system.
 

After implementing the storage logic, you register it in SysFileContentStorage lookup, which tells the system to use your custom storage for file operations.


How to check:


 

You’ll also need a custom file locator (implementing IFileLocator) to specify where files are stored in the file system, and optionally a custom metadata storage (implementing IFileMetadataStorage) if you need to tweak how metadata is handled. 


Our documentation explains more about it: 

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/8.1/back-end-development/api-for-file-management/overview
https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/back-end-development/api-for-file-management/references/ifilecontentstorage
EntityFileLocator class | Creatio Academy

Regards,
Orkhan
 

Show all comments

Hello, colleagues. After generating a report, it is necessary to attach it as a file to the record, in the Files and links detail. The application from "customerfx" is not suitable. Here, it is necessary to automatically select the report form by pressing one button, etc. 

I ask for your help. Perhaps there is somewhere to look at the code. Or you can point to an article in the Academy, or something else.
As a last resort, I will analyze the principle of operation of the application from Ryan (customerfx").
Thank you all.

Like 0

Like

2 comments
Best reply

Not sure if I completely understand, however, if you're wanting to generate a printable and attach to a record, you can do this with a process using the Process File element. This allows you to generate a printable and you can easily attach to a record's files. Then, just wire up the button to run the process. 

Ryan

Not sure if I completely understand, however, if you're wanting to generate a printable and attach to a record, you can do this with a process using the Process File element. This allows you to generate a printable and you can easily attach to a record's files. Then, just wire up the button to run the process. 

Ryan

Ryan Farley,

Thanks, Ryan. That's what I did. I wrote a business process for generating different reports depending on the value of the reference field and adding them to the attached files. In the module, I added a button to call this business process with the transfer of the necessary parameters to it.

Show all comments

Hello

 

It is posible to save a file in creatio from a base64 string? I have a web service that allows me to request a document by an id to an external service and it responds with the document in a base64 string, so I would like to know if it is possible to convert that string into the file and save it in some record on the platform.

 

Thank you 

Like 0

Like

2 comments

Something like this should work:

var base64FileString = Get&lt;string&gt;("Base64File");
var accountId = Get&lt;Guid&gt;("AccountId");
 
var attachFileType = new Guid("529bc2f8-0ee0-df11-971b-001d60e938c6");
var fileName = "SomeFile.docx" // set proper file type in file name
 
var entity = UserConnection.EntitySchemaManager.GetInstanceByName("AccountFile");
var fileEntity = entity.CreateEntity(UserConnection);
fileEntity.SetDefColumnValues();
fileEntity.SetColumnValue("AccountId", accountId);
fileEntity.SetColumnValue("TypeId", attachFileType);
fileEntity.SetColumnValue("Name",fileName);
fileEntity.SetBytesValue("Data", Convert.FromBase64String(base64FileString));
fileEntity.Save();

Ryan

Ryan Farley,

Thank you very much 

Show all comments

Hello,

 

I'm trying to implement a file storage that saves files on a network share instead of the database. I followed the instructions here:  API for file management | Creatio Academy but I'm getting a Cannot be null Parameter name: service error. 

Any help will be appreciated. 

Thanks,

Jose

 

Like 0

Like

1 comments

Good day,

Based on the screenshots, an empty value appears to be passed to a method with the “service” argument. Unfortunately, there's not enough information available to pinpoint the exact cause of the error at this time.
 

To further investigate, it would be necessary to debug and examine what the service returns in the browser console, identify what service it is, and review the function call stack.
 

These issues typically fall under the scope of a development consultation for a deeper investigation. 

If needed, you may want to discuss this with your manager to arrange a consultation.

Thank you!

Show all comments

Hello. 

 

I'm doing an Web services to send a document to sign, the api request the Url of the document so I'm using the following link https:[creatio instance]/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875

 

70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a correspons to the  UId from the SysSchema table where the attachments are stored and the ef68e95e-ef77-eddf-dfa8-685557ee4875 is the Id of the attachment. This URL allows me to dowloand the document to my computer, so I know that is the right link but when I used it in the web service it says that there is no document. 

 

The json of the request is the following 

{
 
    "url_doc": {
 
        "url": "https://151929-crm-bundle.creatio.com/0/rest/FileService/GetFile/70ec5d9f-a55e-4f5c-8f59-30d2c5149c4a/ef68e95e-ef77-eddf-dfa8-685557ee4875",
 
        "name": "Contrato.pdf"
 
    },
 
    "stickers": [
 
        {
 
            "authority": "Vinculada a Correo Electronico por Liga",
 
            "stickerType": "line",
 
            "dataType": "email",
 
            "email":"laura@artica.digital",
 
            "data": "laura@artica.digital",
 
            "imageType": "stroke",
 
            "page": 0,
 
            "rect": {
 
                "lx":74.88173,
 
               "ly":312.32596,
 
               "tx":196.9875,
 
               "ty":373.37885
 
            }
 
        }
 
    ]
 
}

 

When I sent the request the response is 

 

{
    "error": "No document"
}

 

I had try this request with a Dropbox URL and works fine but I need to send the documents that are generated by the Word Reports. That why I'm trying to get the document from Creatio using the URL the API also gives me the option of sending the document using base64 but I dont know how to convert the file easly. 

 

Can you help me please to know what is happenig? 

Thank you

Like 0

Like

4 comments

The reason why this isn't working is because FileService/GetFile requires authentication to read. This is not an anonymous endpoint. The receiver of this, where ever you're sending this URL of the document to, is actually getting a 401 Unauthorized. 

You'd have to either go the route of sending the base64 of the file, or expose an anonymous service in Creatio to provide the file to the other service.

Ryan

Ryan Farley,

Thank you, can you explain me please how can I convert the file to base64 please, I had see some examples but I not sure if I can do it using a script task in a business process or a source code 

Laura Jurado,

The code would look something like this (not tested, but this should get you started). For this, I have two process params, one a uniqueidentifier AccountFileId (an Id of an account file) and second an unlimited text AccountFileBase64. The script task would look something like this:

var fileId = Get&lt;Guid&gt;("AccountFileId");
 
var entity = UserConnection.EntitySchemaManager.GetInstanceByName("AccountFile").CreateEntity(UserConnection);
if (entity.FetchFromDB(fileId))
{
    var base64FileData = Convert.ToBase64String(entity.GetBytesValue("Data"));
    Set("AccountFileBase64", base64FileData);
}

Ryan

Ryan Farley,

Thank you very much. It helped me a lot 

Show all comments

Hello,

 

Does Creatio have any implemented logic for versioning the files? I see that the base File object has a "Version" column that is always set to 1, it seems. Can this behaviour be changed? 

 

Thank you!

Like 1

Like

1 comments

Hello,
 

The logic of the Version column value for the file object is located at the event level of the "File" object process as part of the CrtCoreBase package.



You can use development to create a replacement for the object, where you use your own custom logic to assign a value to the Version column when the object event occurs. This implementation requires knowledge of development and writing source code.
You can learn more about events in the system on Creatio Academy.

You can also create a business process (no-code) that will make the necessary changes to the column values when adding/modifying a record.
 

Thank you.

Show all comments

Hello Community,

 

I need to know if it is possible (and how to proceed if possible) to upload a file into Creatio (in this specific case an audio file) from an external application using OData connection in version 8.0.10. The file need to be uploaded into the attachments detail of a custom section.

 

Thank you!

Like 0

Like

1 comments

Hello Javier,

Regarding the general function of OData, you can find detailed information in the following resource:

 

OData Overview

 

For more specific examples and methods, you can refer to this documentation:

 

OData Methods and Examples

API for file management

Show all comments

Hi,



I am scanning around and couldn't fine anyway on how to add/display the new column I added on my schema. It's a File Datatype which meant to be used to upload any file.



I kept getting:

 "Unhandled Promise rejection: Object { message: "DataValueType.BLOB is not supported" }"

Here's the sample DIFF script I added.

{
				"operation": "insert",
				"name": "TCFileObj",
				"values": {
					"layout": {
						"colSpan": 12, "rowSpan": 1, "column": 0, "row": 5
					},
					"bindTo": "TCFile",
                    "controlConfig": {
                            "fileUpload": true
                        }
				},
				"parentName": "ParentName",
				"propertyName": "items",
				"index": 6
			}





 

Like 0

Like

4 comments

Hello,

The data type "File" doesn't mean to be displayed on the page and therefore you cannot upload files to it using the UI.

If you want to work with files, please use the Attachment detail.

Dmytro Vovchenko,



Is it a datatype not meant to be use in Schema/Object level?

Solem Khan Abdusalam,

 

Hi,

 

Please use a standard and working approach with the "Attachments and notes" detail on the page to upload files. There is no particular documentation or example on how to add DataValueType.BLOB fields on the page, but you can review how the column is added to the system setting with "MenuLogoImage" code page:

and implement the same.

Oleg Drobina,



That's actually a very cool way to start somewhere!

I'll check it out.



I'll post the sample code after making it work.

Show all comments