Genesys CTI User Forum

Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: cavagnaro on November 09, 2017, 06:57:51 PM

Title: Updatel all chains_n into customer chain_id
Post by: cavagnaro on November 09, 2017, 06:57:51 PM
Hi,
Customer needs that when agent updates a custom field by RecordProcessed or UpdateCallCompletitionStats, all chains in that record, update the same value.

Say, if for example, at the start of call we have for chain_id = 73

chain_n = 0 | CUST_FIELD = "" (RH 0)
chain_n = 1 | CUST_FIELD = "" (RH 1)
chain_n = 2 | CUST_FIELD = "" (RH 2)

When agent does a UpdateCallCompletitionStats with RH 0, all other records (chain_n 1 and chain_n 2) also get the same value ending in:

chain_n = 0 | CUST_FIELD = "SOME VALUE" (RH 0)
chain_n = 1 | CUST_FIELD = "SOME VALUE" (RH 1)
chain_n = 2 | CUST_FIELD = "SOME VALUE" (RH 2)


What happens today is that only RH is updated.

chain_n = 0 | CUST_FIELD = "SOME VALUE" (RH 0)
chain_n = 1 | CUST_FIELD = "" (RH 1)
chain_n = 2 | CUST_FIELD = "" (RH 2)

I have tried the option update_all_records = true but doesn't seem to work in the way is needed.
Worst if we do a Reschedule to a new number, then the reschedule doesn't bring the value and is useless at the end.

What would I need to do to update all chains in that chain_id?

Multiple UpdateCallCompletitionStats? For I have tried won't work as seems to update only 1 record always.
Title: Re: Updatel all chains_n into customer chain_id
Post by: hsujdik on November 10, 2017, 04:36:18 AM
I don’t know how this can be achieved in Genesys either, but you can have a trigger on the DB that does the trick (as long as the record is not on “retrieved” state, you should be able to use this)
Title: Re: Updatel all chains_n into customer chain_id
Post by: cavagnaro on November 10, 2017, 11:03:12 AM
That is the issue I think, the AFTER trigger is an idea too but not quite sure if will work...
Do you have a sample trigger by any chance?  :P
Title: Re: Updatel all chains_n into customer chain_id
Post by: hsujdik on November 10, 2017, 01:29:04 PM
[quote author=cavagnaro link=topic=10737.msg48809#msg48809 date=1510311792]
That is the issue I think, the AFTER trigger is an idea too but not quite sure if will work...
Do you have a sample trigger by any chance?  :P
[/quote]
For Oracle?
Title: Re: Updatel all chains_n into customer chain_id
Post by: cavagnaro on November 10, 2017, 01:30:19 PM
Can be
Just to grab the idea


Enviado de meu E6633 usando Tapatalk

Title: Re: Updatel all chains_n into customer chain_id
Post by: hsujdik on November 10, 2017, 04:59:19 PM
for SQL Server would be something like below:

[code]
create or alter trigger dbo.trg_update_chain_data
on <your table name here>
after update as
declare @chainid int
declare @custfield varchar
begin
if trigger_nestlevel() <= 1 -- this prevents recurstion on the trigger
begin
if exists (select 1 from deleted where (cust_field = '') or (cust_field is null) )
and exists (select 1 from inserted where (cust_field <> ''))
begin
select @chainid = chain_id from inserted
select @custfield = cust_field from inserted

update <your table name here> set cust_field = @custfield where chain_id = @chainid
end
end
end
[/code]

For Oracle, I have to dig a little bit more to check how to prevent trigger recursion
Title: Re: Updatel all chains_n into customer chain_id
Post by: cavagnaro on November 10, 2017, 05:04:11 PM
Sql is fine
Will check it
Thanks!

Enviado de meu E6633 usando Tapatalk