So i'm making a simple Creatio app where I want to upload an image, encode it in base64 format, and pass it via WebService to my application.

 

I made a simple page with a button that calls business process where WebService is called.

I also added attachment component, uploaded a few images, and can successfully access the last image in my business process via formulas (get it's name, info ect.)

 

I don't have much experience in C#, so I'm kindly asking if someone could give me an example code how to read the image in Script Task named Base64 Encoder, after it's been fetched in "ImageReader" task, and return/forward encoded B64 image to "API CALL" task.

 

Thanks in advance!

Like 0

Like

7 comments

Hello,

 

First you should add Process file element to your business process where you can get the file and keep it for further usage in the process.

Then in Script Task you can retrieve that file and apply encoding. You can use the following code as an example

 

var files = context.Process.FindFlowElementByName("ObjectFileProcessingUserTask1").GetPropertyValue("ObjectFiles") as ICompositeObjectList<ICompositeObject>;
foreach(var file in files)
{
	if(file.TryGetValue<EntityFileLocator>("File", out EntityFileLocator fileLocator))
	{
		IFile fileItem = UserConnection.GetFile(fileLocator);
		using (System.IO.Stream stream = fileItem.Read())
		{
			/* Retrieve the file content and save it to the array. */
			var content = stream.ReadToEnd();
			var encodedContent = Convert.ToBase64String(content);
			Set<string>("EncodedFile", encodedContent);
		}
	}
}

 

Here ObjectFileProcessingUserTask1 is the name of Process file element in the business process.

Also don't forget to include Terrasoft.File and Terrasoft.File.Abstractions namespaces to the business process. In order to do that open the business process designer, go to the Methods tab and add the namespaces to the Usings list.

You can find more information about file processing in the articles:
https://academy.creatio.com/docs/8.x/no-code-customization/bpm-tools/process-elements-reference/system-actions/process-file-element
https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

Thank you so much for the response.

I have successfully compiled my BusinessProcess, but how do I access 'EncodedFile' in my other tasks?

For example, I want to display it inside Auto-generated page, but I don't see my ScriptTask among my Process Elements in Formula window.

Please have a look at the “Process parameters” tab, as the result of the script execution is written to the “EncodedFile” process parameter

Considering it is a Base64 string, which process parameter type should I choose? Unlimited length text?

 

Also, I would like to get image width and height in the code and save it to parameter as well.

How can I get them in code?

Since Base64 string might be long Unlimited length text type will be a good choice for the parameter that will be used for storing it.

 

In order to get and save image width and height first you have to create 2 process parameters of type Integer (e.g.  ImageWidthParam and ImageHeightParam). Then in Script Task you can get the values using the following code:

 

using (System.IO.Stream stream = fileItem.Read())
{
	using (Image img = Image.FromStream(stream))
	{
		Set<int>("ImageWidthParam", img.Width);
		Set<int>("ImageHeightParam", img.Height);
	}
	/* Retrieve the file content and save it to the array. */
	var content = stream.ReadToEnd();
	var encodedContent = Convert.ToBase64String(content);
	Set<string>("EncodedFile", encodedContent);
} 


Also add System.Drawing namespace to the business process the same way as you added Terrasoft.File and Terrasoft.File.Abstractions namespaces.

 

Thank you so much for the replies!

 

Only thing that doesn't work is that EncodedFile seems to be empty.

When I try to print it inside AutoGeneratedPage as a text field it shows nothing, and when I forward it in a WebService .json body to my API there is no data.

 

Process file element is fetching last 10 records from uploaded files, I tried looking up uploaded files and there are test images there, so there should be valid input to my ScriptTask.

 

Is there something about Process Parameter "EncodedFile" that I should set up differently except setting its type as Unlimited length text? Everything else I left at default values.

The problem that EncodedFile parameter is empty could be that the stream position is at the end, so when you call stream.ReadToEnd(), there's nothing left to read.
You can update a proposed code a bit to make sure that stream position is not at the end before reading from it.

 

/* Retrieve the file content and save it to the array. */
var content = stream.ReadToEnd();
var encodedContent = Convert.ToBase64String(content);
Set<string>("EncodedFile", encodedContent);
using (MemoryStream imageStream = new MemoryStream(content))
using (Image img = Image.FromStream(imageStream))
{
	Set<int>("ImageWidthParam", img.Width);
	Set<int>("ImageHeightParam", img.Height);
}

 

Also I would recommend to debug Script Task code in Visual Studio in case you have some issues to make sure that it's executing as expected.

Show all comments

Hello everyone!

When a user first opens record's form page (the form page consists of a number of tabs), the user is not able to see any tab open, whenever he selects any tab and leaves the page, and then reopens the form page then the previously selected tab is opened. How can we spesify a default tab that user should see when he opens a form page?

Like 1

Like

6 comments

Hello,

You can disable the feature: DisableSaveToProfileSelectedTabIndex, which is responsible for opening the last tab when entering the page, but if you disable it, the first tab should be opened when entering the page, not the last one that was opened.

Best regards,
Malika

Hello, Malika
Thank you for your response. Could you please tell me more about how I can do the solution you have suggested? I tried to change the code of cliend module, but didn't work as expected. 

Malika,

I am using freedom ui pages

Zulaykho,

You don't need to change anything in the code, you can disable the feature through the system UI. To do this, use the link: https://mycreatio.com/0/Flags, but instead of "mycreatio", it should be the name of your site. 

More detailed instructions: https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/platform-customization/interface-control-tools/existing-feature/overview
 

When you go to the features section, you will need to search for DisableSaveToProfileSelectedTabIndex, open the record, and uncheck "enable" checkbox.

Malika,

Thank you a lot Malika, for your response.
But it is already unchecked, what can i do ?

Malika,

I've done several tests enabling and disabling that feature, clearing the cache, logging-off and on.. but the last selected tab in freedom ui is shown when opening the page of any record of the section (in freedom ui).

What can I do?

Thanks

Show all comments

I have a list page, and its data source is a spesefic object we have created.  above the list table there is a search element. What i want is when there is no filter applied the list table should be empty and, when any filter is applied then it should show only the matching resluts. How can i achieve this? What now happening is it is showing all of the existing records, but when i wanted to set up a business rule I could not find any option to access search element.

Like 0

Like

3 comments

And also, when the filter is cleaerd the list should again be empty as there is no filter applied

Zulaykho,

Clear the list isn't an easy task and needs a development team to be involved. Instead, you can prevent the list load by showing the Error message to the customer:

{
	request: "crt.SearchFilterColumnsGroupsRequest",
	handler: async (request, next) => {
		const searchValueLenIsZero = request?.value?.length == 0;
		const isEmptySearchValue = request?.value?.trim().length == 0;
		if (searchValueLenIsZero || isEmptySearchValue) {
			Terrasoft.showErrorMessage("There is no filter");
               } else {
                 await next?.handle(request);
               }
	}
}

Best regards,

Anhelina!

Anhelina,

Thank you a lot for your response! 

Show all comments

Hi 

 

I'm currently using the trial version of Sales Creatio in Chrome and would like to integrate Gmail for better email management. Could someone guide me through the steps or provide tips on how to successfully integrate Gmail with Creatio? Any insights on best practices or potential pitfalls to watch out for would be greatly appreciated!

Please refer a Screen Shot : 



 

Like 0

Like

3 comments

In order to add a gmail account you need to create an app specific password (which means you'll also need 2 factor authentication enabled in gmail also). Then, when adding the gmail account in Creatio you'll provide the app specific password instead of your real one. See https://support.google.com/mail/answer/185833?hl=en

Ryan

Hi Ryan

Despite already using an app-specific password, I'm still encountering errors when trying to integrate Gmail with Creatio. What steps should I take to resolve this issue?

Daniel Poveda,


Hello,
 

1. Please make sure you are using the correct parameters for the Google mail server.

  1. 2. Ensure that the web server of the application and the Email listener server have access to the Gmail server.
     

    3. If you're using a local environment, please verify that the microservice is properly deployed and configured.
     

    4. More information regarding the authorization error can be found in the logs of the application and microservice when attempting to add the mailbox.
     

    5. If you are using the site in the Cloud and the mail service parameters are correct, please contact our support for further analysis. (Support@creatio.com)
     

Thank you for reaching out!

Show all comments

Link to object shows link to DEV environment how to fix

Like 0

Like

1 comments

Hello,

 

Thank you for your question. We are asking you to kindly elaborate more on the issue. A brief step-by-step instruction would be much appreciated.

 

Best regards,

Anastasiia

Show all comments

Hello, when I change Owner, type section also should change, please help how can i do that?

Thanks so much in advanced.

Like 1

Like

2 comments

Hi,

 

You need to set the value for the "type" column using a client-side code and this.set method. This should be added to the "Owner" attribute modification handler method (the handler example was provided in this post for example).

 

Best regards,

Oscar

You can see an article on how to wire up change events on the page here: https://customerfx.com/article/triggering-an-event-when-a-field-is-chan…

As far as setting the value of the Type lookup, a lookup needs an object with two properties to display properly, (1) a value property (the Id of the lookup item) and (2) displayValue (the text of the lookup item). You'd set it like this: 

this.set("Type", {
    value: theIdOfTheTypeItem,
    displayValue: theTextOfTheTypeItem
});

This article on getting started with client side code for Creatio might help https://customerfx.com/article/getting-started-with-writing-code-for-bp…

Ryan

Show all comments

Hi,

I have a Business Process that creates Leads based on incoming mails. The scenario that creates a problem is- Person- X recommends person- Y and sends a recommendation mail. Now receiving this Mail the BP creates a new Lead. Meanwhile person-Y sends a mail describing His needs, following which the BP gets triggered and creates a new Lead for this mail. Currently both the mail refers to Person-Y, and 2 leads are created for Person-Y.  I need to avoid this duplicate Lead creation. I tried to use "Setup duplicate rules" option, but both mails have different names and email ID.

How to avoid this duplicates Lead creation?

 

Like 0

Like

2 comments

Hello Angel,



It is difficult to give an exact answer, but you can try the following approach.



Try to add a search for similar leads to the process of creating leads from the business process.



You can add conditional flows that will check duplicates in the system under certain conditions and direct the process to the appropriate branch.



Best regards,

Bogdan

Bogdan,

 yes we have planned to use conditional flows to check the lead email Id if it is same merge the records or kept them as it is. Thank you Bogdan

Show all comments

Hi Community,

I wanted to bind the access rights data of a dashboard. I tried to bind the data of the dashboard using sysdashboard and filtering it for a particular section. I then exported the package and uploaded in another instance and found that the access rights were not bound. 

Can anyone guide me on how to bind the access rights of a section dashboard.

 

Thank you

Like 0

Like

0 comments
Show all comments