Время создания
Filters

Hello,

I created a validation for telephone numbers as explained in this article: Implement the validation of a field value on a page | Creatio Academy
For testing purposes, I added it to the notes field on the contacts form, and it works fine.


However, I want to add the validation to the communications options on the left side of the form.
How do I bind the validation in the viewModelConfigDiff?
Also, only communication options of type "phone number" should be validated.

 

Thanks,

Robert

Like 0

Like

1 comments

Hello,

Currently there is no way to add the validator using the regular approach with the validators property on the schema. However you can try adding it using the formControl for the ContactCommunicationOptionsItems (but note that this will be applied for phones, email, skype and web (in other words for all communication options)).

 

How to add the validator using formControl:

 

  1. Implement the same validator on some separate field on the page
  2. Find this validator in the context of the crt.HandleViewModelAttributeChangeRequest request execution (like request.$context._validators["AccountAccountCategory_List.value"][0]), but replace AccountAccountCategory_List.value with your attribute name on the page to which the validator is added. Also make sure array with only one element is returned (since you can have several validators for the same field and the array of validators can contain more than 1 element thus ...["AccountAccountCategory_List.value"][0] can return another validator.
  3. In the context of the crt.HandleViewModelAttributeChangeRequest request (connected to the change of the ContactCommunicationOptionsItems attribute) add the following code:

request.$context.getControl("ContactCommunicationOptionsItems").formControl.addValidators(request.$context._validators["AccountAccountCategory_List.value"][0])
 

But replace equest.$context._validators["AccountAccountCategory_List.value"][0] with the needed validator.

 

This is the only way to add the validator for this CommunicationOptions component (but once again note that this will be added to all the other communication options). 

Show all comments

Hi Team,

I'm working on a use case where I have to make database connection & perform some actions. For this, I created source-code file with C# scripting that is properly working.

Query: How can I use below scripting in Process Library using Script task or another node to make db connection & perform the required action.

namespace Terrasoft.Configuration.UsrExternalMSSQLService {

    using System;                  // Basic types (e.g., Exception, etc.)

    using System.Collections.Generic;  // For collections like List, Dictionary, etc.

    using System.Data;             // For DataReader, DataTable, etc.

    using System.Data.SqlClient;   // For SqlConnection, SqlCommand, SqlDataReader

    using System.ServiceModel;     // For WCF (Web Service) contracts

    using System.ServiceModel.Web; // For handling WebInvoke, UriTemplate, etc.

    using System.ServiceModel.Activation; // For ASP.NET compatibility with WCF

    using Newtonsoft.Json;          // For JSON serialization and deserialization

    using Terrasoft.Core;           // For Terrasoft core functionality (e.g., UserConnection)

    using Terrasoft.Core.DB;        // For database-related queries in Terrasoft

    using Terrasoft.Web.Common;     // For web-related functionality (if needed for services)

 

    [ServiceContract]

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

    public class UsrExternalMSSQLService : BaseService

    {

        private string connectionString = "Server=client.server.net;Database=Client_Database;User Id=root;Password=root;";

 

        // Test Database Connection

        [OperationContract]

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

        public string TestDBConnection()

        {

            try

            {

                using (SqlConnection connection = new SqlConnection(connectionString))

                {

                    connection.Open();

                    return "DB Connection Successful!";

                }

            }

            catch (Exception ex)

            {

                return "Connection Failed: " + ex.Message;

            }

        }

        // Get Contact Detail

        [OperationContract]

        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,

            ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetEntityDetail")]

        public string GetEntityDetail()

        {

            string result = "{}";

            try

            {

                using (SqlConnection connection = new SqlConnection(connectionString))

                {

                    connection.Open();

                    string sql= @"select TOP 10 c.AffilaitionName, c.CustomerKey, c.CustomerEmail, c.CustomerFirstName from Customer c";

                

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

                    using (SqlDataReader reader = cmd.ExecuteReader())

                    {

                        result = CreateJson(reader);  // Using external method

                    }

                }

            }

            catch (Exception ex)

            {

                return JsonConvert.SerializeObject(new { error = "Error fetching data: " + ex.Message });

            }

            return result;

        }      

       private string CreateJson(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);

        }

        // End; Get Contact Detail 

    }

}


 

Like 0

Like

1 comments

In the process, you can just create an instance of the class in a Script Task and use it normally. 

var mssqlSvc = new Terrasoft.Configuration.UsrExternalMSSQLService.UsrExternalMSSQLService();
 
if (msssqlSvc.TestDBConnection() == "DB Connection Successful!")
{
    var result = mssqlSvc.GetEntityDetail();
}
 
// etc

Ryan

Show all comments

Hello Community,

Is it possible that when double clicking a record in a list, we are not redirected to the Form page of that record?

Example

  1.  when double clicking a Contact Record in the Accounts Form page, we want nothing to happen.

2) Currently when we double click we are redirected to the Contact Form page

3) We can not allowed to modify the current apge config due to various reasons.

Is there any codesnippet to add in the DataGrid

Sasor

Like 0

Like

1 comments
Best reply

You can add a property rowDoubleClick with an empty object to remove the ability to open the record by double clicking on a row: 

{
   "operation": "merge",
   "name": "TheListNameHere",
   "values": {
      "rowDoubleClick": {}
   }
}

Ryan

You can add a property rowDoubleClick with an empty object to remove the ability to open the record by double clicking on a row: 

{
   "operation": "merge",
   "name": "TheListNameHere",
   "values": {
      "rowDoubleClick": {}
   }
}

Ryan

Show all comments

Hello Creatio community!,

there is an duplicate data within an object i created, is there a way to include the new object that is not in the dropdown list when adding a new rule in "Set up dulicate rules" ?

Like 0

Like

0 comments
Show all comments

I wrote a .cs script in one of my business processes for testing purposes. That introduced compilation error for my package. Now I have deleted the process but the compilation errors wont go away. How do I fix this?

Like 0

Like

1 comments

Hello,

Please provide a screenshot of the compilation errors.

Show all comments