Question

Modify existing update lead name process

Hello,

I am trying to midfy the existing update lead name process. I am trying to follow how this community post explains it.

 https://community.creatio.com/questions/modify-existing-process-giving-lead-name 

Creatio has updated since then, and does not look the same. I have tried to recreate it please refer to the screen shot.

 

This is not working.

Any help appreciated.

Thanks!

Like 0

Like

3 comments

Dear Tyler,

 

In order to implement the required functionality please do the following:

1. Create a replacing object for the “Lead” object.

2. Add a new event sub-process:

 

 

 

3. In the sub-process, add the following code to the “Methods” tab:

 

namespace Terrasoft.Configuration

{

    using DataContract = Terrasoft.Nui.ServiceModel.DataContract;

    using Newtonsoft.Json;

    using Newtonsoft.Json.Linq;

    using System;

    using System.Collections.Generic;

    using System.Collections.ObjectModel;

    using System.Collections.Specialized;

    using System.Data;

    using System.Drawing;

    using System.Globalization;

    using System.IO;

    using System.Linq;

    using System.Web;

    using Terrasoft.Common;

    using Terrasoft.Common.Json;

    using Terrasoft.Configuration.PRM;

    using Terrasoft.Core;

    using Terrasoft.Core.Configuration;

    using Terrasoft.Core.DB;

    using Terrasoft.Core.DcmProcess;

    using Terrasoft.Core.Entities;

    using Terrasoft.Core.Factories;

    using Terrasoft.Core.Process;

    using Terrasoft.Core.Process.Configuration;

    using Terrasoft.GlobalSearch.Indexing;

    using Terrasoft.UI.WebControls.Controls;

    using Terrasoft.UI.WebControls.Utilities.Json.Converters;

    #region Class: Lead_CustomEventsProcess

    public partial class Lead_CustomEventsProcess<TEntity>

    {

        #region Methods: Public

        public override void UpdateLeadName() {

            var esq = new EntitySchemaQuery(Entity.Schema);

            esq.AddColumn("Account");

            esq.AddColumn("Contact");

            esq.AddColumn("QualifiedContact.Name");

            esq.AddColumn("QualifiedAccount.Name");

            esq.AddColumn("LeadType.Name");

            var leadEntity = esq. GetEntity(UserConnection, Entity.PrimaryColumnValue);

            if (leadEntity != null) {

                var columnAccount = leadEntity.GetTypedColumnValue<string>("Account");

                var columnContact = leadEntity.GetTypedColumnValue<string>("Contact");

                var columnQualifiedContact = leadEntity.GetTypedColumnValue<string>("QualifiedContact_Name");

                var columnQualifiedAccount = leadEntity.GetTypedColumnValue<string>("QualifiedAccount_Name");

                var columnLeadType = leadEntity.GetTypedColumnValue<string>("LeadType_Name");

            

                string contactName = !string.IsNullOrEmpty(columnQualifiedContact) ? columnQualifiedContact : columnContact;

                string accountName = !string.IsNullOrEmpty(columnQualifiedAccount) ? columnQualifiedAccount : columnAccount;

            

                string additionalLeadName = StringUtilities.ConcatIfNotEmpty(new[] { contactName, accountName }, ", ");

                string leadName = StringUtilities.ConcatIfNotEmpty(new[] { columnLeadType, additionalLeadName }, " / ");

                if (!string.IsNullOrEmpty(leadName) && leadName.Length >= 500) {

                    leadName = leadName.Substring(0, 500);

                }

                if (!String.IsNullOrEmpty(leadName)) {

                    Update updateLeadQuery = new Update(UserConnection, Entity.Schema.Name);

                    // change the value of lead name for example

                    leadName = "Test Lead Name";

                    updateLeadQuery.Set("LeadName", Column.Parameter(leadName));

                    updateLeadQuery.Where("Id").IsEqual(Column.Parameter(Entity.PrimaryColumnValue));

                    updateLeadQuery.Execute();

                }

            }

        }

        #endregion

    }

    #endregion

}

 

4. Save and publish the sub-process and the object.

 

5. Please see the screenshot with the result below:

 

 

Best regards,

Norton

Thank you for the recommendation.

I get this error when trying to implement that.

Dear Tyler,

 

In order to find the root cause of the issue please provide us with a source code from the “Methods” tab. Also, please provide us with a product name and version of the application that you use.

 

Best regards,

Norton

Show all comments