Hello,


I'm working on a service where I have to fetch data from Database. For this, service file 'ClientDBService' was created.

(Code):
----------
using System;

using System.Data;

using System.Data.SqlClient;

using System.Collections.Generic;

using System.ServiceModel;

using System.ServiceModel.Web;

using System.ServiceModel.Activation;

using Newtonsoft.Json;

using Terrasoft.Web.Common;

 

namespace Terrasoft.Configuration.ClientDBService

{

    [ServiceContract]

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

    public class ClientDBService : BaseService

    {

        // SQL Connection String

        private string connectionString = "Server=my-client-sql-server;Database=client_db;User ID=root;Password=root;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

 

        [OperationContract]

        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetUsersData")]

        public string GetUsersData()

        {

            string result = "{}"; // Default empty JSON

 

            try

            {

                using (SqlConnection connection = new SqlConnection(connectionString))

                {

                    connection.Open();

                    string sql = "SELECT * FROM Users"; // Change the table name as needed
 

                    using (SqlCommand cmd = new SqlCommand(sql, connection))

                    using (SqlDataReader reader = cmd.ExecuteReader())

                    {

                        result = ConvertDataReaderToJson(reader);

                    }

                }

            }

            catch (SqlException sqlEx)

            {

                result = JsonConvert.SerializeObject(new { Error = "SQL Error: " + sqlEx.Message });

            }

            catch (Exception ex)

            {

                result = JsonConvert.SerializeObject(new { Error = "General Error: " + ex.Message });

            }

            return result;

        }

 

        private string ConvertDataReaderToJson(IDataReader dataReader)

        {

            var list = new List>();

 

            while (dataReader.Read())

            {

                var record = new Dictionary();
 

                for (int i = 0; i < dataReader.FieldCount; i++)

                {

                    string fieldName = dataReader.GetName(i);

                    object fieldValue = dataReader.IsDBNull(i) ? null : dataReader.GetValue(i);

                    record.Add(fieldName, fieldValue);

                }

                list.Add(record);

            }

            return JsonConvert.SerializeObject(list);

        }

    }

}

Query:  

1. How can I connect SQL DB using script task?

2. Is it possible to keep above code `GetUsersData()` in separate service-file & keep only db-connection code in script task?

Also, I found something related to Point 2, that is following:


var userConnection = Get("UserConnection"); 

class_name demo= new class_name(userConnection); 

demo.some_method(); 

return true; 
 


Platform: Creatio:Energy 8.2v (Freedom UI)


 

Like 0

Like

1 comments

Hello,

Database connection using Script task doesn't relate to the specific Creatio functionality. Please read the C# documentation to find the answer to your question.

 

Show all comments

Hi,

 

I'm working on Freedom UI. According to requirements, I have to make connection with Client's DB to fetch data to show on UI.

How can I integrate client's database in Creatio?

Platform: Creatio: Energy (Freedom UI)

Like 0

Like

1 comments

Hello,

 

You can use integrations to retrieve data.

Such as Odata, Custom Service, etc.

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platform/category/integrations-tools


 

Show all comments

There are cases when a record is inserted directly from db and the bp doesn't trigger on object signal(Record Added/Modified), how do I proceed in these cases?
 

Like 1

Like

5 comments

A direct database insert/update won't trigger a signal needed for a process to start. Only option I can think of is to flag the record in some way and have a process running on a timer looking for the flagged records.

Ryan

Hello, 

As Ryan indicated,

Unfortunately, it’s not possible through the database.

Regards, 
Orkhan

Thank you both Ryan and Orkhan for your answers

In my case is there any workaround I can use, besides what Ryan mentioned above?

Hi,

 

if you have control over the insert/update process, you could set up a stored procedure in the DB and call it after the insert/update operation. The stored procedure could call the ProcessEngineService.svc via web request.

 

Here is an example with SQL server: How To Call A Web Service From SQL Server (c-sharpcorner.com)

This is the documentation of the ProcessEngineService.svc: Service that runs business processes | Creatio Academy

 

I read it is possible for Postgre, too, but I don't have any experience with it.

Also, if you have a cloud instance of Creatio you might be lacking the permissions to install components to make this work...

 

BR,

Robert

Thanks Robert

I will give it a try.

Show all comments

Hi guys! I was wondering if there's a direct way to connect Creatio with Airtable...

 

Thanks in advance,

ALfredo

Like 0

Like

2 comments
Best reply

Hello,

 

In the basic version, there is no integration with Airtable.

However, you can integrate using other option - https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

 

Best regards,

Yuliya

Hello,

 

In the basic version, there is no integration with Airtable.

However, you can integrate using other option - https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

 

Best regards,

Yuliya

Thank you!

Show all comments

It seems that any indexes (unique or otherwise) created in Creatio config are created to ignore case. This is not good from a data perspective, and prevents actual uniqueness checking in cases where the case of the characters matter. We need to be able to configure unique indexes to be case sensitive - I think ideally this would be the default option and you could check a checkbox in the config to ignore case if required, but certainly you should be able to generate normal database unique indexes which are case sensitive.

1 comments

Hello,

Thank you for this idea, we will translate it to our developers and they will analyze what can be done.

Show all comments

I want to update MaxFileSize and ActiveFileContentStorage using a query to save time. But whenever I tried to run the query from SQL Console it successfully update the values in the database but they are not reflected in the Creatio Portal.

 

When I add the query in the SQL file in advanced settings and run it, it updates the data in the database and in the portal as well. The problem is that it's not dynamic which will kill the purpose of using the query.

 

In other words, if I have to go and change the value in that file and run it again then we can do the same for the system settings as well.

 

Can anyone help me with that?

 

Thanks in advance.

Like 0

Like

1 comments

Hello Syed,

 

The issue here is that these values are also storred in cache and direct updating of these values are not reflected in the cache. That's why you have old values after updating values from the database directly.

 

What should be done after updating values in the database is Redis flush. But this will lead to all users to be logged out from the system and obviously cannot be performed during business hours for the application (or users should be notified that the Redis will be flushed soon). After Redis flush new system settings values will be used when working in the application.

Show all comments

Where can i see the Schema details in the Creatio to edit it.

Like 0

Like

1 comments

Hello,

 

In Creatio, you can access the Schema details and make edits in the Configuration section

Show all comments

Hello Community,

There is a bug in the system regarding the 'Contact in Folder' object, because apparently uses InsertQuery directly into the database, instead of the InsertQuery class.This object doesn't throw signals. How can we capture the event of an added record in such a scenario ?

Thank you

Sasori

Like 0

Like

10 comments

Hello,

 

Could you please provide us with an example of the InsertQuery which is not working?

Hello,

Object name is ContactInFolder. If you try to catch an event ( when contact is added to a Static Folder) through a Business Process, the business Process wont trigger.

My question is how to catch the event of adding Contacts to a Static Folder?

Sasori Oshigaki,

 

Hello,

 

And is the option with the business process with the timer that starts each 1 hour and reads records that were created in the previous 1 hour suitable here? You can read data and process it in this way. 

Hello Oleg,

Thats the solution we are providing for the moment. Thought that it was better to do something more performant, that doesnt overload the system by executing each hour.

Thank you

Hello,

Besides the option that Oleg provided, another variant is to create a trigger in the DB because normal events like OnInserted won't work with INSERT INTO.

Hello Dmytro,

Thank you for your answer. Is there anywhere in the system a similiar implementation of a trigger, so that we can take it as a reference while we develop our own ?

Thank you,

Sasori

The system rarely uses database triggers so it would be hard to provide a suitable example.

It would be better to search trigger examples in the DB documentation

Thank you for your reply Dmytro!

 

Hello Dmytro,

I created this trigger

CREATE OR ALTER Trigger [dbo].[trigger_InsertContactInFolderAfterEvent] 
ON [dbo].[ContactInFolder]
AFTER INSERT AS
BEGIN
SET NOCOUNT ON;
DELETE cf
FROM ContactInFolder AS cf
inner join Contact as co on cf.ContactId=co.Id
where co.[Name] like 'V3%'
END;

It practically deletes Contacts (whose name start with V3),that are added in the Static Folders. Does this added trigger may cause problems for the overall system ?

Thank you Sasori

Dmytro Vovchenko,

Hi Dmytro

Any Update ?

All the best Sasori

Show all comments

Hi community,

Anybody aware of the use of SysProcPersistentStore table in creatio? A customer has 19GB of data in the table but we don't know where the data comes from.

 

Thank you in advance.

Have a good one!

Like 0

Like

1 comments

Hi!

 

It's a known issue. We'll gladly provide a solution to your particular instance in case you submit a request to our Technical Support team via support@creatio.com.

 

Thank you!

Show all comments

Is it possible to export an existing database schema into a creatio datamodel? Or from an ERD Data export?

 

I use lucidchart to create a model of my database, it has export functions for MySQL, PostgreSQL, SQL Server, Oracle SQL and a similar platform as creatio, Quickbase. 

 

Does creatio support such an import wizard?

Like 1

Like

1 comments

Hello Pascal,

 

unfortunately this is not quite possible.

The thing is that you can export the DB in such way, but you will not have any objects in the system.

So we would recommend sticking to the standard way. Also, we will register this option as a wish for the dev team to implement it in the future.

 

Regards,

Gleb.

Show all comments