Author Topic: Search target in a list by meeting 2 conditions  (Read 2209 times)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7622
  • Karma: 56330
Search target in a list by meeting 2 conditions
« on: January 11, 2019, 07:05:58 AM »
Hi guys
I have a request to search a target based in 2 parameters. Say X and Y.
So if X = 1 and Y = 1 then target is A
If X = 1 and Y = 2 then target is B
If X = 2 and Y = 3 then target is C
If X = 4 and Y = 99 then target is B and so on...


So I was thinking in use Lists Lookup based on the inner values but didn't work as all I can query is 1 item


Any clue how could I do this inside CME without going to a DB query or similar? Mixed patterns are real small so would like to keep it inside Genesys to easyness of maintenance


Any idea is welcome or guide ;)
Thanks!

Offline terry

  • Sr. Member
  • ****
  • Posts: 324
  • Karma: 35
Re: Search target in a list by meeting 2 conditions
« Reply #1 on: January 12, 2019, 06:08:14 AM »
What exactly is use case when List Lookup doesn't work?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7622
  • Karma: 56330
Re: Search target in a list by meeting 2 conditions
« Reply #2 on: January 12, 2019, 06:12:33 AM »
You mean if no condition is met? Well in theory that wouldn't happen as would create all possible combinations.
The default would be to send the call to another set of skills based on another parameters as service type.

Offline terry

  • Sr. Member
  • ****
  • Posts: 324
  • Karma: 35
Re: Search target in a list by meeting 2 conditions
« Reply #3 on: January 12, 2019, 06:47:50 AM »
But wouldn't ListGetDataCfg[List, X, Y] work (or I miss the point, sorry)?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7622
  • Karma: 56330
Re: Search target in a list by meeting 2 conditions
« Reply #4 on: January 12, 2019, 10:24:24 AM »
Well that search works but only for 1 key and I see this way


List Object: TARGETS
Item Service A
Key x value 1
Key y value 1
Item Service B
Key x value 1
Key y value 2
Item Service C
Key x value 2
Key y value 3


So I need to query based on Key x and y which are unknown


Something like


select item_service from TARGETS where x = %1 and y = %2


Under ListGetDataCfg how to do this? As far as I can see I only can send 1 key to query...
If I am wrong or not seeing the whole picture please can you clarify me?


Thanks a lot as usual Terry

Offline terry

  • Sr. Member
  • ****
  • Posts: 324
  • Karma: 35
Re: Search target in a list by meeting 2 conditions
« Reply #5 on: January 12, 2019, 02:56:41 PM »
Ok, understood now.

Just originally thought to have list organized a bit differently (sort of index list. like INDEX tables):
Items are values of parameter X.
Inside each item keys are value of parameter Y and their values are corresponding Services.

If there is necessity to work in paradigm list item presents service with attributes, probably ListGetDataCfg not very straightforward. Something like that still might work I think:
 - create combined key like x_y and its values will be accordingly combined values of these parameters, like your sample will turns into:
List Object: TARGETS
Item Service A
  Key x_y value 1_1
Item Service B
  Key x_y value 1_2
Item Service C
  Key x_y value 2_3
etc

In such case to find service the following probably might work:
list= ListGetDataCfg[TARGETS, '*', 'x_y']
in list you get something like ServiceA:1_1|ServiceB:1_2|ServiceC:2_3 and after that it has to be scanned for proper pair value (like one having 1_2 as value) and its key to be obtained.


Better solution might be using FindConfigObject function.
 1. list= FindConfigObject[CFGTransaction, 'type=21|name=TARGETS']     - in list will be placed entire transaction object
 2. annex= KVListGetListValue[list, 'annex']  - in annex will be entire user properties of the TARGETS object something like list of sublsists:
Service A
   x=1
   y=1
Service B
   x=1
   y=2
Service C
   x=2
   y=3.

3. what left is performing something like "select item_service from TARGETS where x = %1 and y = %2" on this list object:
    sublist= KVListFindPairs[annex, 'x:1|y:2']   - going to returns sublist of annex having only those "Services" that has x=1 and y=2 in its properties. Something like:
Service B
   x=1
   y=2
 Any elements of received "Service" can be accesed as well as key (service name) itself (KVListGetKey[sublist, 1])

 


 


Offline hsujdik

  • Hero Member
  • *****
  • Posts: 539
  • Karma: 29
Re: Search target in a list by meeting 2 conditions
« Reply #6 on: January 15, 2019, 11:43:11 AM »
What if X is the section name and Y is the option name of the list?