" /> Updatel all chains_n into customer chain_id - Genesys CTI User Forum

Author Topic: Updatel all chains_n into customer chain_id  (Read 1831 times)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Updatel all chains_n into customer chain_id
« on: November 09, 2017, 06:57:51 PM »
Advertisement
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.

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Updatel all chains_n into customer chain_id
« Reply #1 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)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Updatel all chains_n into customer chain_id
« Reply #2 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

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Updatel all chains_n into customer chain_id
« Reply #3 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?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Updatel all chains_n into customer chain_id
« Reply #4 on: November 10, 2017, 01:30:19 PM »
Can be
Just to grab the idea


Enviado de meu E6633 usando Tapatalk


Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Updatel all chains_n into customer chain_id
« Reply #5 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

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: Updatel all chains_n into customer chain_id
« Reply #6 on: November 10, 2017, 05:04:11 PM »
Sql is fine
Will check it
Thanks!

Enviado de meu E6633 usando Tapatalk