API filter by phone number

Hi Community there,

Could anyone please help, many thanks!

I want to user  field  'phone_mobile' to filter all related user via calling endpoint:   XXXX/Contacts/filter

I can get some records by setting pload in the request:

pload = {
        "filter":[
            {"$or":[
                    {"phone_work":"+61 8 8373 6420"},
                    {"phone_mobile":"+61 403 995 372"}
                    ]
            }
        ]
    }
But my problem is the format of the number is different between what is in the sugar system and the parameter we pass:
1. the number passed vi parameters will be the format  without space, say: "+61883736420";
2. the number in sugar system can be with or without '+', same for the space :  61419876746,  0477 151 598, +61 419 019 954 ,etc.
So, my question is:
If the format of the phone number passed from command is fixed.
Instead of getting all results first and pre-processing phone number and then matching the number passed from command.
When I pass the number, can I pre-process the result and then filter when calling API?
Is there any endpoint can do that?
Parents
  • Hi Dmytro,

    Thanks a lot for your reply.

    Do you have any sample about logic builder please? 
    I’m totally new to sugar...

    The number format in sugar system is inconsistent since it’s typed by every single individual.

    I just want to make the phone number have a consistent format so that I can filter better.

    Thanks a lot!

  • Hello Sophie,

    Sorry for the delay with the response.
    Could you specify first if you are trying to filter users or contact?

    Actually, I see 3 types of efforts that could help with the challenge:

    1) to set up phone validation logic, preventing users from entering non-formatted phones

    2) to format entered phone automatically - each time the user profile is saved - according to the preconfigured logic

    3) to set up a custom endpoint for the external call, so that users keep their phones formatted in Sugar as they want, but get them formatted on the fly for search purposes when the endpoint is called

    The first option is preventive, the second is supportive, and the third is "to configure for me" - due to a relatively high computing load, the last wouldn't work if you have dozens of thousands of records (like Contacts) but should work for hundreds (like the number of Users)

    Which of 3 would better work for your circumstances?

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • Hi Dmytro,

    Thank you for your reply.

    First, I'm trying to filter the module 'Contacts' and it has 30K records. I want to get id when the phone number field matches.

    So I guess the third option is not suitable.

    As to the first option, when you're saying 'it is preventive', do you mean it's forbidden to do so ?

    And how can I do the second option, please?

    Thanks a lot!

  • Hi Sophie,

    I agree with Jeroen reply that the easiest way is to export all Contacts (e.g. create Rows & Columns Report with Contact ID and Phone Number and export it), then to clean up phones using Excel and then using out-of-the-box import to import updated file (Sugar will update Contacts by ID if you select 'Create new records and update existing records' in Import wizard).

    Once data is cleaned up, to prevent such scenario in the future it is nice to have a check on Phone fields that an entered value contains only + and numbers. For this task you could code as mentioned or try out Logic Builder configuration tool.

    Here is an example of such validation:

    And of course the result in the interface:

    ...and a zip package to try validation on your instance:)

    z20210601_flowchart_lb60b614ad12af40_26596112.zip

Reply
  • Hi Sophie,

    I agree with Jeroen reply that the easiest way is to export all Contacts (e.g. create Rows & Columns Report with Contact ID and Phone Number and export it), then to clean up phones using Excel and then using out-of-the-box import to import updated file (Sugar will update Contacts by ID if you select 'Create new records and update existing records' in Import wizard).

    Once data is cleaned up, to prevent such scenario in the future it is nice to have a check on Phone fields that an entered value contains only + and numbers. For this task you could code as mentioned or try out Logic Builder configuration tool.

    Here is an example of such validation:

    And of course the result in the interface:

    ...and a zip package to try validation on your instance:)

    z20210601_flowchart_lb60b614ad12af40_26596112.zip

Children