YannickRe / spfx-msgraph-peoplesearch

Show and search users from your organization with an SPFx web part, through Microsoft Graph.
40 stars 33 forks source link

Search filters: Search by phone numbers #28

Closed MMAtHome closed 2 years ago

MMAtHome commented 2 years ago

Hi,

This code is really great and works well in modern SP. Since lockdown, and more home working, users are getting calls from colleagues personal mobile phones. It would be great if they could search their user list using the telephone number to verify the caller. I have already implemented search changes to allow, for example, search by Department by changing resultQuery.query and including department:${this.searchParameter} but using mobilePhone in place of department rarely returns results. Does anyone have any ideas on this?

YannickRe commented 2 years ago

I reached out to the Graph Team. $search on anything other than mail or displayName would fallback to a startsWith $filter request. When testing out $filter directly I get an error message from Graph (although the API documentation states that it is supported), which might explain why $search also isn't returning data.

I'll keep you informed!

MMAtHome commented 2 years ago

Yannick,

Thanks so much for coming back to me on this and for speaking to the Graph team. It would be great to see this work - perhaps the API will get an update at some point.

Very best regards,

Martin.

On Sat, Jul 24, 2021, 14:21 Yannick Reekmans @.***> wrote:

I reached out to the Graph Team. $search on anything other than mail or displayName would fallback to a startsWith $filter request. When testing out $filter directly I get an error message from Graph (although the API documentation states that it is supported), which might explain why $search also isn't returning data.

I'll keep you informed!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YannickRe/spfx-msgraph-peoplesearch/issues/28#issuecomment-886053009, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZD3XKCMMMCICWPVNMWX63TZK45TANCNFSM5AXW4ZVA .

YannickRe commented 2 years ago

So, this took a while but I come with information 😀.

My tests with $filter were failing because I didn't use the correct magic header parameter (Consistencylevel: eventual) and forgot the $count=true. It also seems that you need to encode the + character in a phone number to %2B, otherwise $filter does not return the expected results.

All of that applies to $search as well BUT it currently only works on the /beta endpoint of Graph, and the team is looking into it 😀.

Hope that gives you an insight into some potential causes of the malfunction you are experiencing.

MMAtHome commented 2 years ago

Hi.

Thanks so much for keeping me in the loop on this. It would be great to see this functionality in the "non-beta" endpoint. I guess with anything Microsoft it's a case of "watch this space".

Thanks again,

Martin

On Thu, Aug 5, 2021 at 1:44 PM Yannick Reekmans @.***> wrote:

So, this took a while but I come with information 😀.

My tests with $filter were failing because I didn't use the correct magic header parameter (Consistencylevel: eventual) and forgot the $count=true. It also seems that you need to encode the + character in a phone number to %2B, otherwise $filter does not return the expected results.

All of that applies to $search as well BUT it currently only works on the /beta endpoint of Graph, and the team is looking into it 😀.

Hope that gives you an insight into some potential causes of the malfunction you are experiencing.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YannickRe/spfx-msgraph-peoplesearch/issues/28#issuecomment-893428541, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZD3XKLQJDLYYINP7N2E4DT3KBSZANCNFSM5AXW4ZVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

YannickRe commented 2 years ago

They investigated this further, and all of this is due to an old Graph encoding bug that only manifested with $search. This is fixed in /beta but because there are already production apps that implement the workaround, they can't easily push the fix the v1.0.

To make $search work with the +-sign, you need to do double encoding 🤦‍♂️. Encode the + to %2B and then encode the % to %25, resulting in %252B. Example:

$search="mobilePhone:%252B1 860

Up to you to see how you want to take this knowledge into your customizations, but this is what the PG has told me and I have validated to be correct 😀

MMAtHome commented 2 years ago

Thanks so much for your email. I guess we are still in the situation that, for telephone numbers, $search will still only work for "starts with" rather than "contains", so I don't think this is going to completely work for us, but knowing that the double encoding works is definitely a step in the right direction. Thanks again, Martin

On Wed, Aug 11, 2021 at 9:42 AM Yannick Reekmans @.***> wrote:

They investigated this further, and all of this is due to an old Graph encoding bug that only manifested with $search. This is fixed in /beta but because there are already production apps that implement the workaround, they can't easily push the fix the v1.0.

To make $search work with the +-sign, you need to do double encoding 🤦‍♂️. Encode the + to %2B and then encode the % to %25, resulting in %252B. Example:

$search="mobilePhone:%252B1 860

Up to you to see how you want to take this knowledge into your customizations, but this is what the PG has told me and I have validated to be correct 😀

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YannickRe/spfx-msgraph-peoplesearch/issues/28#issuecomment-896626949, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZD3XK3SFAR4QNUVSGFEUDT4IZXTANCNFSM5AXW4ZVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

YannickRe commented 2 years ago

Yes, it'll still be startsWith and I am not sure if there is a change on the horizon soon. Sorry! Can this issue be closed?

MMAtHome commented 2 years ago

Yes, thank you very much. Please close the issue.

On Wed, Aug 11, 2021 at 10:30 AM Yannick Reekmans @.***> wrote:

Yes, it'll still be startsWith and I am not sure if there is a change on the horizon soon. Sorry! Can this issue be closed?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/YannickRe/spfx-msgraph-peoplesearch/issues/28#issuecomment-896662302, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASZD3XLO6N6DKBR2QFQEUWDT4I7LVANCNFSM5AXW4ZVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .