Hi Community,



How to convert the following SQL query into ESQ so that it can be used in the Script task Process element. 

 

SELECT TOP 1 SalesOwnerId 

FROM [Lead] 

WHERE SBLBranchLocationId ='060183EE-C2F3-4EDF-853C-59E28026EAD6' 

  AND LeadTypeId='669BC3A8-DFDB-4E53-8AAE-B643C2D6C677' 

  AND SalesOwnerId IS NOT NULL 

GROUP BY SalesOwnerId 

ORDER BY COUNT(SalesOwnerId) ASC

Like 0

Like

1 comments

Hi,

If you specifically need to use ESQ then take a look at this discussion where this topic was discussed.

However, in your case you can use Select class, with it you can easily use expressions like GROUP BY or ORDER BY.

Show all comments

I am getting meaningless Compilation errors , any ideawhat it is about ? 

namespace Terrasoft.Core.Process
{
 
	using System;
	using System.Collections.Generic;
	using System.Collections.ObjectModel;
	using System.Drawing;
	using System.Globalization;
	using System.Text;
	using Terrasoft.Common;
	using Terrasoft.Configuration;
	using Terrasoft.Core;
	using Terrasoft.Core.Configuration;
	using Terrasoft.Core.DB;
	using Terrasoft.Core.Entities;
	using Terrasoft.Core.Process;
	using Terrasoft.Core.Process.Configuration;
	using Terrasoft.UI.WebControls.Utilities;
 
	#region Class: UsrProcess_7b09d28TravelAgencyDev1MethodsWrapper
 
	/// <exclude/>
	public class UsrProcess_7b09d28TravelAgencyDev1MethodsWrapper : ProcessModel
	{
 
		public UsrProcess_7b09d28TravelAgencyDev1MethodsWrapper(Process process)
			: base(process) {
			AddScriptTaskMethod("ScriptTask2Execute", ScriptTask2Execute);
			AddScriptTaskMethod("ScriptTask3Execute", ScriptTask3Execute);
			AddScriptTaskMethod("ScriptTask4Execute", ScriptTask4Execute);
		}
 
		#region Methods: Private
 
		private bool ScriptTask2Execute(ProcessExecutingContext context) {
			string sender="AutoAddVisits";
			string msgbody="something";
			MsgChannelUtilities.PostMessage(UserConnection,sender,msgbody);
			return true;
		}
 
		private bool ScriptTask3Execute(ProcessExecutingContext context) {
			var frequency="frequencyInDays";
			switch (frequency) {
			         case "Daily":
			            Set(frequency, 1);
			                        break;
			                    case "Weekly":
			                        Set("frequency", 7);
			                        break;
			                    case "Monthly":
			                        Set("frequency", 30);
			                        break;
			                    default:
			                       break;
			 }
			return true;
		}
 
		private bool ScriptTask4Execute(ProcessExecutingContext context) {
			var travelOfferId = "TravelId"; 
			var travelOfferSchemaName = "TravelOffers";
			var travelOfferEsq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, travelOfferSchemaName);
			travelOfferEsq.addColumn("TravelOfferFrequency");
			var travelOffer = travelOfferEsq.getEntity(travelOfferId);
 
			var tourSchemaName = "Tours";
			var tourEsq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, tourSchemaName);
			var tourCollection = new Collection();
 
			var currentDate = new Date();
			var firstTour = tourCollection.add(tourEsq.createEntity(UserConnection));
			firstTour.set("TravelOffer", travelOfferId);
			firstTour.set("TourDate", currentDate);
 
			var travelOfferFrequency = travelOffer.get("UsrTravelOfferFrequencyId").displayValue;
			var tourDate = currentDate;
			for (var i = 1; i < 8; i++) {
			    switch (travelOfferFrequency) {
			        case "Daily":
			            tourDate.setDate(tourDate.getDate() + 1);
			            break;
			        case "Weekly":
			            tourDate.setDate(tourDate.getDate() + 7);
			            break;
			        case "Monthly":
			            tourDate.setDate(tourDate.getDate() + 30);
			            break;
			        default:
			            throw new UnknownException("Invalid travel offer frequency");
			    }
			    var tour = tourCollection.add(tourEsq.createEntity(UserConnection));
			    tour.set("TravelOffer", travelOfferId);
			    tour.set("TourDate", tourDate);
			}
 
			tourCollection.saveAll({
			    isExternal: true,
			    success: function() {
			        // The tour entities have been saved
			    },
			    failure: function() {
			        // An error occurred while saving the tour entities
			    }
			});
		}
 
		#endregion
 
	}
 
	#endregion
 
}

 

Like 0

Like

2 comments

Hello,

We need more information to solve your problem, please contact our support team - support@creatio.com

Pavlo Sokil,

I sent you a mail 

Show all comments

Hello Community, 

 

I wanted to perform two actions on click of a button

1. Saves the fields in the tab page 

2. Navigate to next tab 

Right now we are using the crt.SaveRecordRequest. This only saves the page. 

 

Any suggestions is really helpful 

 

Thanks

Gargeyi.G

Like 0

Like

4 comments

Hello,

This article will show you how to navigate to a new page on a Freedom UI page: 

https://customerfx.com/article/navigating-to-a-page-via-code-in-a-creat…

If you want to open an edit page for a record, or an add page, this article outlines how to do that: 

https://customerfx.com/article/opening-an-edit-page-to-add-or-edit-a-re…

Ryan

Also, as far as having the button trigger both - there are two routes you can take. 

Route 1 - If you'd always go to this other page after saving, you could just do that when the save request is triggered. This article shows how to listen for when the page is saved, then you could navigate to the other page from there: https://customerfx.com/article/adding-code-to-the-save-event-of-a-creat…

Route 2 - If you're only wanting to save, then go to this other page, when your own button is clicked, and not for all saves, then you can wire up your own handler for your button. This article shows how to to that: https://customerfx.com/article/adding-a-button-to-execute-custom-code-o… In the handler, you'd save the page, then navigate to the other page. If you go this route (creating a custom request for your button). It would look like this:

{
	request: "cfx.clickMeButtonClicked",
	handler: async (request, next) =&gt; {
		// make sure you've added the "@creatio-devkit/common" as mentioned in the articles			
		const handlerChain = sdk.HandlerChainService.instance;
 
		// first save the record
		await handlerChain.process({
			type: "crt.SaveRecordRequest",
			$context: request.$context
		});
 
		// now navigate to the other page, this navigates to the orders section
		await handlerChain.process({
			type: "crt.OpenPageRequest",
			schemaName: "OrderSectionV2",
			$context: request.$context
		});
 
		return await next?.handle(request);
	}
}

Ryan

Ryan Farley,

Please note that it's best to pass context to each handlerChain.process call. So, in your example, the second call should be:

		// now navigate to the other page, this navigates to the orders section
		await handlerChain.process({
			type: "crt.OpenPageRequest",
			schemaName: "OrderSectionV2",
			$context: request.$context
		});

 

Oleksandr Khardikov,

Thanks for that. I've updated the code in my reply for completeness and also the articles on my website.

Ryan

Show all comments

We are trying to implement the MiContact Center connector for Creatio but are having some issues.

 

We can make outgoing calls (using the phone icon) but the system is not recognising incoming calls.

 

Can someone advise as to what we should see in the UI when making and receiving calls, and also what I need to do within the app to make this function fully?

Like 0

Like

1 comments

Hi Kieron,

 

The connector is compatible with MiContact Center version 9.0. Could you tell us the name of your telephony product and its version?

Show all comments

Hi Community,

 

Any idea how to display the "Details" record in email template. In Template designer there is option to get data from Related Objects. However, there is no way to add records from child table.

 

 

Like 1

Like

1 comments

Hi Fulgen,

This marketplace add-on from SalesUp might fit your needs to add one-to-many data in an Email template: 

https://marketplace.creatio.com/app/salesup-enhanced-template-macros-cr…

Ryan

Show all comments

Hello Community, 

 

Is it possible to bind the title of the form page from "New Record"  to a field value on load of a page in freedom UI.

 

Thanks

Gargeyi.G

Like 0

Like

1 comments

Hello,

You can change that by adding a handler like this - note this will change the value from "New record" when adding a new record for the page:

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.HandleViewModelInitRequest",
		handler: async (request, next) =&gt; {
			const result = await next?.handle(request);
 
			const cardState = await request.$context.CardState;
			if (cardState == "add" || cardState == "copy") {
				request.$context.HeaderCaption = "Add a new something";
			}
 
			return result;
		}
	}
]/**SCHEMA_HANDLERS*/,

As far as binding it to some page value, you could use the same but first get a value from the page. Something like this:

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.HandleViewModelInitRequest",
		handler: async (request, next) =&gt; {
			const result = await next?.handle(request);
 
			const cardState = await request.$context.CardState;
			if (cardState == "add" || cardState == "copy") {
				request.$context.HeaderCaption = "Add a new something";
			}
			else {
				// get a value from the page
				const someValue = request.$context.someAttributeOnThePage;
				request.$context.HeaderCaption = someValue;
			}
 
			return result;
		}
	}
]/**SCHEMA_HANDLERS*/,

Ryan

Show all comments

Perform verification whenever a user adds or modifies a daily tour offer as follows: if the total number of active daily tours exceeds the system setting value , saving a record should not be permitted. Instead, a user should receive a message informing that no more than “N” daily tours can be active at a time. “N” is the system setting value.

 

Here is my code : 

asyncValidate: function(callback, scope) {
    this.callParent([
        function(response) {
            if (!this.validateResponse(response)) {
                return;
            }
            this.validateTravelOfferTour(function(response) {
                if (!this.validateResponse(response)) {
                    return;
                }
                callback.call(scope, response);
            }, this);
        }, this
    ]);
},
 
validateTravelOfferTour: function(callback, scope) {
    // Fetch the Maximum Number Of Daily Periodical Editions System Setting
    var mySetting = Terrasoft.SysSettings.cachedSettings.Usr_Max_Number_Activity_Tours;
    var FrequencyObject=this.get("UsrTravelOfferFrequency");
    if(!FrequencyObject){
        if(callback){
            callback.call(scope,{
                success:true
            });
        }
        return;
    }
    var FrequencyId=FrequencyObject.value;
    //create query
    var esq=this.Ext.create("Terrasoft.EntitySchemaQuery",{
        rootSchemaName:"UsrTravelOffers"
    });
    //esq.addAggregationSchemaColumn("UsrActive",Terrasoft.AggregationType.)
    var ActivityFilter = esq.createColumnFilterWithParameter(0, "UsrActive", "1");
    var frequencyFilter=esq.createColumnFilterWithParameter(0,"UsrTravelOfferFrequency",FrequencyId);
    esq.filters.addItem(frequencyFilter);
    esq.filters.addItem(ActivityFilter);
 
    // Aggregation to get the Count of resulting Query
    esq.addAggregationSchemaColumn("UsrActive", Terrasoft.AggregationType.COUNT, "ActiveOffers");
    //run query
    // Get the entire esq result colelction
    esq.getEntityCollection(function(result) {
        if (result.success && result.collection) {
            // Store the Count of Filtered Records to a variabble
            var items = result.collection.getItems();
            if(items.length>0){
                esqresult=items[0].get("ActiveOffers");
            }
            if(esqresult==mySetting){
                if(callback){
                    callback.call(this,{
                        success:false,
                        message:"no more than 3 daily tours can be active at a time."
                    });
                }
            }else
                if(callback){
                    callback.call(scope,{
                        success:true
                    });
                }
        }
    },this);
},

and this is the error :

{"responseStatus":{"ErrorCode":"InvalidObjectStateException","Message":"Condition with type \"Between\" must contain two expressions in the left part.","Errors":[]},"rowsAffected":-1,"nextPrcElReady":false,"success":false}

 

Like 0

Like

3 comments
Best reply

Since it's more of a question about the ESQ, the first parameter for createColumnFilterWithParameter is a value from Terrasoft.ComparisonType. You have a 0 (zero) there, which means a BETWEEN. Instead it should be 3, which is EQUAL. It's better to use the value Terrasoft.ComparisonType.EQUAL so the code is easier to read.

var ActivityFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrActive", "1");
var frequencyFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,"UsrTravelOfferFrequency", FrequencyId);

Ryan

Hello,

 

Thanks for your question. Please note that posting certification questions is not encouraged on our platform.

 

Thank you for understanding!

 

Best regards,

Anastasiia

Since it's more of a question about the ESQ, the first parameter for createColumnFilterWithParameter is a value from Terrasoft.ComparisonType. You have a 0 (zero) there, which means a BETWEEN. Instead it should be 3, which is EQUAL. It's better to use the value Terrasoft.ComparisonType.EQUAL so the code is easier to read.

var ActivityFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrActive", "1");
var frequencyFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,"UsrTravelOfferFrequency", FrequencyId);

Ryan

Ryan Farley,Thank you that was it.

Show all comments

Hi Community, 



Is there anyone who might be able to help me with the code below? I am trying to filter a lookup column, by the value of another lookup column on the same page.

Specifically, my column "PrimaryContact" should be filter Contacts where the "Account" is equal to the "UsrCompanyName" of the same page. 



I've tried many things in the "Value" for rightExpression, but can't seem to get it to work. The rest of the code seems okay because if I add a Guid of an Account to the value, it filters fine. 



Thanks!



 

"LookupAttribute_j53fgnq_List_BusinessRule_Filter": {
					"value": {
						"filterType": 6,
						"isEnabled": true,
						"items": {
							"CustomFilters": {
								"filterType": 6,
								"isEnabled": true,
								"items": {
									"cb855fc4-4526-475a-beea-8e41a7f5a439": {
										"comparisonType": 11,
										"filterType": 1,
										"isEnabled": true,
										"leftExpression": {
											"expressionType": 0,
											"columnPath": "Account"
										},
										"rightExpression": {
											"expressionType": 2,
											"parameter": {
												"dataValueType": 1,
												"value": "$PDS.UsrCompanyName.Id"
											}
										},
										"trimDateTimeParameterToDate": false
									}
								}
							}
						}
					}
				}, 
 

 

Like 2

Like

4 comments
Best reply

Hi Harry,

It would be easier to handle the request for when the lookup requests its data source and then add the filters to that request since you'd have access to page data.

When the lookup is activated (user clicks the dropdown) it sends a crt.LoadDataRequest. You can listen for that and then add the filters there. The request would look something like this: 

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.LoadDataRequest",
		handler: async (request, next) =&gt; {
		    // the data soruce name will be the lookup attribute name + "_List_DS"
			if (request.dataSourceName !== "LookupAttribute_46uzwvy_List_DS") {
				return await next?.handle(request);
			}
 
			// get other page values
			const compId = request.$context.UsrCompanyName.value;
 
			// add filter
			request.parameters.push({
				type: "filter",
				value: {
						"filterType": 6,
						"isEnabled": true,
						"items": {
							"CustomFilters": {
								"filterType": 6,
								"isEnabled": true,
								"items": {
									"cb855fc4-4526-475a-beea-8e41a7f5a439": {
										"comparisonType": 11,
										"filterType": 1,
										"isEnabled": true,
										"leftExpression": {
											"expressionType": 0,
											"columnPath": "Account"
										},
										"rightExpression": {
											"expressionType": 2,
											"parameter": {
												"dataValueType": 1,
												"value": compId
											}
										},
										"trimDateTimeParameterToDate": false
									}
								}
							}
						}
			});
 
			return await next?.handle(request);
		}
	}
]/**SCHEMA_HANDLERS*/,

As a side note, for the filter, I believe something along these lines should work. It's close the working, but the end result request shows in the network tab that the filter key and filter values get added separately to the filters array causing a server error. Hopefully we'll get more details on this sort of thing soon:

(Note, the below doesn't work yet, but sharing it in case someone else gets it to work)

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.LoadDataRequest",
		handler: async (request, next) =&gt; {
		    // data soruce name is lookup attribute + "_List_DS"
			if (request.dataSourceName !== "LookupAttribute_46uzwvy_List_DS") {
				return await next?.handle(request);
			}
 
			let filters = new sdk.FilterGroup();
			filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Type.Name", "Partner");
 
			// add filter
			request.parameters.push({
				type: sdk.ModelParameterType.Filter,
				value: filters
			});
 
			return await next?.handle(request);
		}
	}
]/**SCHEMA_HANDLERS*/,

Ryan

Hi Harry,

 

In case you doubt about the filtration on the column you can create a test list based on the object of your lookup column and specify the needed filtration there:

and

save the page and open the code. As a result you will see an autogenerated code of the working filtration that then can be applied to the column:

HI Oleg, 



Thank you. This example works well when applying a static filter. However, it seems not to work the same when trying to apply filter by page data. 



Do you have any example how to translate this same method so that I can filter a lookup column by page data? 



Thank you 

Hi Harry,

It would be easier to handle the request for when the lookup requests its data source and then add the filters to that request since you'd have access to page data.

When the lookup is activated (user clicks the dropdown) it sends a crt.LoadDataRequest. You can listen for that and then add the filters there. The request would look something like this: 

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.LoadDataRequest",
		handler: async (request, next) =&gt; {
		    // the data soruce name will be the lookup attribute name + "_List_DS"
			if (request.dataSourceName !== "LookupAttribute_46uzwvy_List_DS") {
				return await next?.handle(request);
			}
 
			// get other page values
			const compId = request.$context.UsrCompanyName.value;
 
			// add filter
			request.parameters.push({
				type: "filter",
				value: {
						"filterType": 6,
						"isEnabled": true,
						"items": {
							"CustomFilters": {
								"filterType": 6,
								"isEnabled": true,
								"items": {
									"cb855fc4-4526-475a-beea-8e41a7f5a439": {
										"comparisonType": 11,
										"filterType": 1,
										"isEnabled": true,
										"leftExpression": {
											"expressionType": 0,
											"columnPath": "Account"
										},
										"rightExpression": {
											"expressionType": 2,
											"parameter": {
												"dataValueType": 1,
												"value": compId
											}
										},
										"trimDateTimeParameterToDate": false
									}
								}
							}
						}
			});
 
			return await next?.handle(request);
		}
	}
]/**SCHEMA_HANDLERS*/,

As a side note, for the filter, I believe something along these lines should work. It's close the working, but the end result request shows in the network tab that the filter key and filter values get added separately to the filters array causing a server error. Hopefully we'll get more details on this sort of thing soon:

(Note, the below doesn't work yet, but sharing it in case someone else gets it to work)

handlers: /**SCHEMA_HANDLERS*/[
	{
		request: "crt.LoadDataRequest",
		handler: async (request, next) =&gt; {
		    // data soruce name is lookup attribute + "_List_DS"
			if (request.dataSourceName !== "LookupAttribute_46uzwvy_List_DS") {
				return await next?.handle(request);
			}
 
			let filters = new sdk.FilterGroup();
			filters.addSchemaColumnFilterWithParameter(sdk.ComparisonType.Equal, "Type.Name", "Partner");
 
			// add filter
			request.parameters.push({
				type: sdk.ModelParameterType.Filter,
				value: filters
			});
 
			return await next?.handle(request);
		}
	}
]/**SCHEMA_HANDLERS*/,

Ryan

Thank you, Ryan. That worked perfectly. 

Show all comments

Good day!

Tried to set up your application on our system. But unfortunately, there were errors. Nothing happens when you save the settings for a recurring activity. Activities are not duplicated (although there is no error).

Maybe not all categories can use them?

please contact me and help)

Thank you)

Like 0

Like

7 comments

This package in the marketplace is for MSSQL systems only. If this is a could system it's most likely a Postgresql system, not MSSQL. The package will install on a Postgresql system, but won't work (and I believe doesn't show any errors). Do you know if the system it's installed on is MSSQL database or not? 

Ryan

Seems bizarre there is no Postgres support given most Creatio cloud environments run on this.

Lewis Pull,

I agree. This would be a very useful add-on. I would love to see this work with new systems (actually should be added as a base part of Creatio)

Ryan

Hi Yana, Ryan and Lewis,

The developer does not have plans to add PostgreSQL compatibility. Therefore, we decided to remove this add-on from the Marketplace.

Also, we have sent feedback to our R&D team about including such functionality in Creatio out of the box.

Irina Lazorenko,

Hi Irina, do you know if there are any plans for this agreed? This is a feature we would really benefit from.

Very bizarre that this is not a standard feature within any CRM to be honest.

@Irina Lazorenko, any plans to implement this?

Show all comments

Hi guys,

I am working on a custom "ContactFieldConverter" [the thing that splits the Contact's FullName imported by excel/ webserveces etc] in order to split new contact's names into "GivenName" and "Surname", and preventing the OOTB function from filling in the "MiddleName" column.

In order to do so, I created a custom ContactGsFieldConverter in my package and inserted the value of the Separator and Converter in the Lookup "ShowNamesBy" and sysSetting "ContactFieldConverter".

[myContactGsFieldConverter code:]

 

 namespace Terrasoft.Configuration {
	using System;
	using System.Linq;
	using System.Text;
	using Terrasoft.Common;
	using Terrasoft.Configuration;
 
	#region Class: myContactGsFieldConverter
 
	/// <summary>
	/// Contact "Full name" field converter class.
	/// Separates "Full name" string using "Given name Surname" rule.
	/// </summary>
	public class myContactGsFieldConverter : IContactFieldConverter
	{
 
		#region Properties: Public
 
		/// <summary>
		/// Contact "Full name" separator characters array.
		/// </summary>
		private char[] _separator = { ' ' };
		public char[] Separator {
			get {
				return _separator;
			}
			set {
				_separator = value;
			}
		}
 
		#endregion
 
		#region Methdos: Public
 
		/// <summary>
		/// <see cref="IContactFieldConverter.GetContactSgm"/>
		/// </summary>
		/// <remarks>
		/// After splitting <paramref name="name"/> first element will be used as <see cref="ContactSgm.GivenName"/>,
		/// Everything else as <see cref="ContactSgm.Surname"/>.
		/// </remarks>
		ContactSgm IContactFieldConverter.GetContactSgm(string name) {
			var sgm = new ContactSgm();
			if (string.IsNullOrEmpty(name)) {
				return sgm;
			}
 
			var array = name.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
			switch (array.Length) {
				case 0:
					return sgm;
				case 1:
					sgm.GivenName = array[0];
					break;
				case 2:
					sgm.GivenName = array[0];
					sgm.Surname = array[1];
					break;
				default:
					sgm.GivenName = array[0];
					StringBuilder sb = new StringBuilder();
					for (var i = 1; i <= array.Length - 1; i++) {
						sb.AppendFormat("{0} ", array[i]);
					}
					sgm.Surname = sb.ToString().Trim();
					break;
			}
			return sgm;
		}
 
		/// <summary>
		/// <see cref="IContactFieldConverter.GetContactName"/>
		/// </summary>
		/// <remarks>
		/// "Full name" string will be created using "Given name [Middle name] Surname" rule.
		/// </remarks>
		public string GetContactName(ContactSgm sgm) {
			var concatChar = Separator.FirstOrDefault();
			return new[] { sgm.GivenName, sgm.MiddleName, sgm.Surname }.ConcatIfNotEmpty(concatChar.ToString());
		}
		#endregion
	}
	#endregion	
}

The converter is not working. I tried to debug and noticed that my contact converter is returned as null to [this is a method in the Contact c# object]: 

public virtual void SetSgm(Contact contact) {
			if (contact == null) {
				return;
			}
			contact.FillSgmFields(GetContactConverter());
		}

Do you know if I need to do something specific in case of separate-assembly package?

ie: Using a different namespace for the converter/ setting the converter path in a different way within the system setting/ recreate the method on the Contact Object in my custom package.





Thank you in advance!

Like 1

Like

5 comments

Hello Federica,

 

I just completed the test - convertor works in the assembly package as well. The code (since we don't need middle name) was:

namespace Terrasoft.Configuration {
    using System;
    using System.Linq;
    using System.Text;
    using Terrasoft.Common;
    #region Class: UsrCustomContactFieldConverter
    /// &lt;summary&gt;
    /// Contact "Full name" field converter class.
    /// Separates "Full name" string using "Surname Given name" rule.
    /// &lt;/summary&gt;
    public class UsrCustomContactFieldConverter : IContactFieldConverter
    {
        #region Properties: Public
        /// &lt;summary&gt;
        /// Contact "Full name" separator characters array.
        /// &lt;/summary&gt;
        private char[] _separator = { ' ' };
        public char[] Separator {
            get {
                return _separator;
            }
            set {
                _separator = value;
            }
        }
        #endregion
        #region Methdos: Public
        /// &lt;summary&gt;
        /// &lt;see cref="IContactFieldConverter.GetContactSgm"/&gt;
        /// &lt;/summary&gt;
        /// &lt;remarks&gt;
        /// After splitting &lt;paramref name="name"/&gt; first element will be used as &lt;see cref="ContactSgm.Surname"/&gt;,
        /// second element as &lt;see cref="ContactSgm.GivenName"/&gt;
        /// &lt;/remarks&gt;
        ContactSgm IContactFieldConverter.GetContactSgm(string name) {
			var sgm = new ContactSgm();
			if (string.IsNullOrEmpty(name)) {
				return sgm;
			}
			var array = name.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
			switch (array.Length) {
				case 0:
					return sgm;
				case 1:
					sgm.GivenName = array[0];
					break;
				default:
					sgm.GivenName = array[0];
					sgm.Surname = array[1];
					break;
			}
			return sgm;
		}
        /// &lt;summary&gt;
        /// &lt;see cref="IContactFieldConverter.GetContactName"/&gt;
        /// &lt;/summary&gt;
        /// &lt;remarks&gt;
        /// "Full name" string will be created using "Surname Given name" rule.
        /// &lt;/remarks&gt;
        public string GetContactName(ContactSgm sgm) {
            var concatChar = Separator.FirstOrDefault();
            return new[] { sgm.Surname, sgm.GivenName }.ConcatIfNotEmpty(concatChar.ToString());
        }
        #endregion
    }
    #endregion
 
}

and then this convertor was registered in the database (ShowNamesBy table). As a result newly created contacts where full name is Test 1 2 had the first (Test) and last (1) name only while middle name was skipped.

Hi Oleg Drobina,

Could you share with me the record registered in the database table ShowNamesBy for a separate assembly pkg?

Hence, in case the site receives a Contact "Name": "Federica Rose Cattani" I don't want to "lose" the "MiddleName" but I want it to be concat to the "Surname". That's what I did in the converter shared. 

Federica,

 

Hi,

 

Sorry, I guess I was wrong with the package. Tested the same approach today and it didn't work until I unchecked the "Compile into separate assembly" checkbox in the package settings. So in your case you need to also do the same to make the converter work.

 

The insert was:

INSERT INTO ShowNamesBy (Name, Separator, Converter) VALUES (N'UsrCustomContactFieldConverter', N' .,;', N'Terrasoft.Configuration.UsrCustomContactFieldConverter');

 

Oleg Drobina,

Ok! In my case I can't "undo" the separate assembly since it contains customer's implementation and separate assembly it's way faster to compile.

The actual possible workaround would be to implement a second package without separate assembly containing only the custom ContactGsFieldConverter, am I correct?

Hello, some conclusion regarding this, in Spain we have the same problem with names than in Italy

Show all comments