0

I'm trying to return a list of contacts that could match multiple "PHONE" values. Right now I can get a list that matches one phone value but not an array of phone values. Here's what I have:

let contactList = await bitrix.call('crm.contact.list', {
        "filter": {
            "PHONE": phoneArray,    //example ["1112223344","5556651234"]
        },
        "select": ["*","EMAIL","PHONE"]
    });

I'm basing this off their API documentation that shows how to match one phone value here

There's also another article I found that mentions using a "LOGIC":"OR" in a filter that could potentially work. It's written in PHP so I'm not exactly sure how it translates to javascript.

thefastlane
  • 29
  • 1
  • 8

1 Answers1

1

You can use crm.duplicate.findbycomm (https://training.bitrix24.com/rest_help/crm/auxiliary/duplicates/crm.duplicate.findbycomm.php):

BX24.callMethod(
    "crm.duplicate.findbycomm", 
    {
        entity_type: "CONTACT",
        type: "PHONE",
        values: [ "8976543", "11223355" ],
    }, 
    function(result) 
    {
         if(result.error())
              console.error(result.error());
         else
         {
              console.dir(result.data());          
         }
    }
);

but there are limitations:

An array containing up to 20 e-mails or phone numbers

Maybe it will do use batch (https://training.bitrix24.com/rest_help/js_library/rest/callBatch.php)

Unfortunately crm.contact.list can't match multiple "PHONE" values

maxkrasnov
  • 284
  • 2
  • 7
  • I shouldn't need to max out the 20 email/phone number limit so this should be perfect. Thanks! – thefastlane Jul 02 '21 at 16:50
  • I'm finally getting around to implementing this answer and it seems like the api is only looking for exact matches for phone. If I give the "values" option an array of partial phone numbers (example ["123456","1234567"]) is there a way I can return partial CRM matches? – thefastlane Jul 14 '21 at 15:30
  • @thefastlane it seems not – maxkrasnov Jul 16 '21 at 12:05