Announcement

Collapse
No announcement yet.

Complex search query for API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Complex search query for API

    Hello,

    I'm looking forward to search for a specific phone number in Accounts. I get this phone number from PBX as we are call. But they are not in same format. PBX delivers for example +49832112340 an espoCRM Accout has a number like (08321) 1234-0. As the data in espoCRM is imported daily from another system I can't be sure it as always the same format. So it is no solution to bring the PBX number to this format. I would like to strip down all phone numbers in espoCRM to just digits.
    After some research I found out this is done in sql with the REPLACE function. But is there a chance to call this within an API Query string?
    The aim is to search successfully for 0832112340 although database contains (08321) 1234-0

    Code:
    from espo_api_client import EspoAPI
    
    client = EspoAPI('http://espocrm', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
    
    
    # Get accounts with search params
    params = {
        "select": "id,phoneNumber",
        
        "where": [
            {
                "type": "equals",
                "attribute": "phoneNumber",
                "value": '(08321) 1234-0',
            },
        ],
    }
    print(client.request('GET', 'Account', params))​

  • #2
    You can manage the format of phone number in the Dial Plan in the PBX (Asterisk).

    Comment


    • daniel.huber@whuber.de
      daniel.huber@whuber.de commented
      Editing a comment
      I think this would work if the phone numbers would always be in the format (08321) 1234-0 but there are also bad things like 08321/12340 of +49 8321 12340 which makes it complicated. I need to somewhere strip down to just numbers before comparing.

  • #3
    Try searching by 'phoneNumberNumeric' attribute.

    Comment


    • daniel.huber@whuber.de
      daniel.huber@whuber.de commented
      Editing a comment
      After some web research I only found this when using php code. Can I use this within an api call as well?
Working...
X