Время создания
Filters
auto
Assignment
of
Lead
Owner
to
Contact
with
least
number
oof
Leads

I’m working on a business process that randomly assigns contacts as owners of new leads, but only after checking how many leads are already assigned to each contact. The goal is to ensure that each new lead is assigned to the contact who currently owns the fewest leads.

I need guidance or a solution for implementing this logic so that the system correctly identifies the contact with the lowest lead count and assigns the new lead to them.

Purpose is to distribute leads fairly and ensure every lead gets timely attention.

Like 0

Like

2 comments

What I would likely do is:

  1. Create a database view that provides a list of users that are potential lead owners with a count of open leads for each (see sample below)
  2. Expose the view as an object (see here)
  3. In a process when a new lead is created, add a Read Data element to read from the object above and sort by the open lead count in ascending order. The user read will be the one with the fewest open leads to assign the lead to.

The view could be something like this (this is for postgres and is not tested). You might need to adjust which users are included if you don't want to consider all users (maybe with a join to SysUserInRole to check if they belong to a role?)

create or replace view "UsrVwLeadOwnerCount"
as
 
select 
    con."Id",
    con."CreatedById",
    con."CreatedOn",
    con."ModifiedById",
    con."ModifiedOn",
    con."ProcessListeners",
    con."Id" as "UsrContactId",
    coalesce(leadstat."NumLeads", 0) as "UsrOpenLeads"
from 
    "Contact" con
 
    inner join "SysAdminUnit" adm
    on con."Id" = adm."ContactId" and adm."SysAdminUnitTypeValue" = 4
 
    left join (
        select 
            l."OwnerId", 
            count(l."Id") as "NumLeads"
        from 
            "Lead" l
            inner join "QualifyStatus" qs on l."QualifyStatusId" = qs."Id"
        where 
            qs."IsFinal" = false
        group by 
            l."OwnerId"
    ) as leadstat on con."Id" = leadstat."OwnerId"
 
where
    adm."Name" not in ('Supervisor','Mandrill','SysPortalConnection')
    and 
    adm."Active" = true

(I'd possibly add another subquery for most recently assigned lead date, so you could add a secondary sort on that in case multiple users have the same open lead count). 

Ryan

Hello,

You can implement this logic in a business process, but it cannot be done using standard elements only - a Script Task is required to correctly identify the contact with the lowest lead count.

Here is the recommended approach:

1) Use a Read Data element to retrieve all eligible contacts. Make sure it returns a collection of records.

2) Use a subprocess that runs for each item in this collection. Inside the subprocess, add another Read Data element to count how many leads are currently assigned to that specific contact (using the Owner field or your custom ownership field). Pass the result back to the parent process through process parameters.

3) In the parent process, use a Script Task to analyze the collected results and determine which contact has the lowest lead count.

4) Finally, use a Modify Data element to assign the selected contact to the new lead.

This approach ensures that the system always selects the contact with the smallest workload and distributes leads fairly.

Show all comments
hide
funnel_chart
remove
filter
graph
Sales_Creatio
8.0

The funnel shows all possible stages, after which it outputs data only to those fields that we filter. And it is necessary that the filtered fields are not shown, hidden or deleted. It will not be possible to get it through the observer because it comes as one monolithic object, not different fields
For example hide the second and the third row.

Like 1

Like

0 comments
Show all comments
local instance
redis
LocalizableString
foreignkey

23503: insert or update on table "SysLocalizableValue" violates foreign key constraint
This issue is linked to Creatio’s localization system. The table SysLocalizableValue stores

Root Cause: Redis Cache Conflict

The problem almost always comes from Redis, not the database.

If multiple Creatio environments (Dev, Test, Prod, etc.) share:

  • the same Redis server, and
  • the same Redis database index (DB number)

then their cached culture data becomes mixed. Creatio loads culture IDs from another environment, causing invalid keys and triggering the 23503 foreign key violation.

Solution : 

  • Use a different Redis database index for each Creatio instance in ConnectionString.
  • Flush the Redis.
  • Restart Creatio.

 

Like 2

Like

Share

0 comments
Show all comments

Since a few days , I get this error : "Terrasoft.Common.InvalidObjectStateException: Specify data type for parameter "P1" with null value." when calling a select command in my script tasks. The way is call them is like this : 

  public Guid Get_bankaccountid(string bankaccount)
 {
     Guid bankaccountid = new Guid();
     string ourBankAccountTable = "UsrOurBankaccount";
     var userconnection = UserConnection.Current;
     var entitySchemaManager = userconnection.EntitySchemaManager;
     var entitySchema_ourbank = entitySchemaManager.GetInstanceByName(ourBankAccountTable);
     var bankrec = new QueryParameter(bankaccount);
     var select_bank = new Select(userconnection)
         .Column("Id")
         .Column("UsrName")
         .Column("UsrActive")
         .From(ourBankAccountTable)
         .Where("UsrName").IsEqual(bankrec)
         as Select;
     using (DBExecutor dbExecutor_bank = userconnection.EnsureDBConnection())
     {
         using (System.Data.IDataReader reader = select_bank.ExecuteReader(dbExecutor_bank))
         {
             if (reader.Read())
             {
                 if ((bool)reader["UsrActive"])
                 {
                     bankaccountid = (Guid)reader["Id"];
                 }
             }
         }

     }
     return bankaccountid;
 }

This code has run for months, and is now causing problems in my clouded deployments. On my local system however, it runs perfectly. Has anyone any idea what has changed?

 

Greetings,

 

Vincent

 

 

 

Like 0

Like

1 comments

Maybe try modifying the Where part of the Select? Try changing from this:

.Where("UsrName").IsEqual(bankrec)

To this: 

.Where("UsrName").IsEqual(Column.Const(bankrec))

Not sure if this is the issue, but worth trying.

Ryan

Show all comments
TechHour
#CreatioAcademy
GoogleAnalytics
marketing
CreatioMarketing

Learn how to turn insights into action with Google Analytics inside Creatio.
In this 1-hour session, we’ll walk you through setting up analytics, tracking key user interactions, and leveraging data to optimize your processes and boost performance.

Perfect for marketers and analysts who want to make smarter, data-driven decisions.

 

When: December 3, 9:00 AM EST/ 3:00 PM CET

Join tomorrow: https://creatio-global.zoom.us/meeting/register/mLa-5as5RQO7FoweAX0CFQ

Like 1

Like

Share

0 comments
Show all comments