-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3409 from microsoft-search/develop
v4.10.0
- Loading branch information
Showing
104 changed files
with
65,615 additions
and
67,670 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,15 @@ contact [[email protected]](mailto:[email protected]) with any additio | |
|
||
## "Sharing is Caring" | ||
|
||
## "PnP Modern Search Office Hours" | ||
If you are stuck on an issue or just need a peer review of your PnP Modern Search based idea, we have Office Hours. | ||
|
||
You can sign up for a 15 min timeslot and a member of the community will set up a Teams call, where you can show and tell about the issue. | ||
Office hours is every second Tuesday at mid afternoon UTC(0). | ||
|
||
Sign up [here](https://aka.ms/pnp/modernsearchofficehours), and please note that not all requests might be granted if there are more requests than timeslots. | ||
|
||
|
||
## Disclaimer | ||
|
||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
docs/scenarios/Setup-Results-web-part-to-show-birthdays.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
A common requirement for intranets is to show birthdays of employees. | ||
And as the SharePoint User Profile Application has a property for birthdays, it is a natural choice to use search to show birthdays of employees. | ||
|
||
(as of writing this (2023), the Graph API does not have a property for birthdays, so we can't use the Graph API to get the information) | ||
|
||
|
||
|
||
The tricky part is that in the User profile application the birthday value is store is a rather usual datatype "date no year" | ||
|
||
![Birthday in the User Provisioning Service](../assets/../scenarios/assets/Setup-Results-web-part-to-show-birthdays/BirthdayUPA.png) | ||
|
||
|
||
In my tenant the SPS-Birthday property was mapped to RefinableDate00 and the actual value in the property is 2000-[the date]: | ||
|
||
![Managed Property value](../assets/Setup-Results-web-part-to-show-birthdays/refinabledate00.png) | ||
|
||
(use the magnificent [SP Editor tool](https://chrome.google.com/webstore/detail/sp-editor/ecblfcmjnbbgaojblcpmjoamegpbodhd) or [SP Search Query Tool](https://github.com/pnp/PnP-Tools/blob/master/Solutions/SharePoint.Search.QueryTool/README.md) to inspect the managed properties) | ||
|
||
|
||
|
||
So, the query had to be something like "those accounts where RefinableDate00 = 2000 + the value of today's date | ||
|
||
|
||
|
||
In KQL we have the token "today" that will give us today's date, but as far as I know, we can't get the components the date consist of, like Month and Day. | ||
|
||
Luckily, the PnP Modern search provides additional Tokens, see [Tokens](https://microsoft-search.github.io/pnp-modern-search/usage/search-results/tokens/) | ||
|
||
|
||
|
||
So the final query is: | ||
|
||
**RefinableDate00=2000-{CurrentMonth}-{CurrentDate}T00:00:00Z** | ||
|
||
|
||
|
||
( and of cause a criteria to exclude former employees, like SPS-HideFromAddressLists<>1) | ||
|
||
![Birthday web part](../asserts/../scenarios/assets/Setup-Results-web-part-to-show-birthdays/birthdays.png) | ||
|
102 changes: 102 additions & 0 deletions
102
docs/scenarios/Setup-Results-web-part-to-show-work-anniversaries.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
Getting PnP Modern Search to show work anniversaries should be easy enoght, right? Just add a couple of managed properties and a couple of web parts and you are done. Well, not quite. | ||
|
||
The problem is that date manipulation in KQL is hard at best and sometimes impossible. In order to find a work anniversary you must compare Today and the Hiredate managed property, but ONLY the day and month part. | ||
|
||
Calculating how many years the employee has been with the company is also required and it seems like there is no way to get that using KQL. | ||
|
||
![upa](../scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/upa.png) | ||
|
||
## Objective | ||
|
||
We want to be able to display two options: | ||
- Employees having a work anniversary today, and also how many years they have been with the company | ||
- Employees having a work anniversary within the next 7 days + number of years. | ||
|
||
## How to cheat | ||
In order to achieve the objectives, I had to get: | ||
- The account | ||
- The hiredate, but with the year segment being the current year | ||
- The number of years the employee has been with company at the next anniversary | ||
|
||
![birthdayAndHiredateSynclist](..\assets\Setup-Results-web-part-to-show-work-anniversaries\BirthdayAndHiredateSyncList.png) | ||
|
||
Lets add birthdayThisYear while I was at it, in order to be able to show upcoming birthdays. | ||
|
||
|
||
The basic idea is that we want to change the hiredate from eg. 10/26/2005 to 10/26/2023 as that allows us to compare Today with this value 😀 | ||
(RefinableDate12 is mapped to the HiredateThisYear property) | ||
|
||
Who is having a work anniversary today? | ||
|
||
*RefinableDate12=Today* | ||
|
||
Anniversary within the next x days is also a piece of cake: | ||
|
||
*RefinableDate12<{Today+7} AND RefinableDate12>{Today}* | ||
|
||
## Implementation | ||
Asking the intern to keep the list above in sync would be a cruel and unusual punishment, and hence actually forbidden in the USA, something to do with a constitution or something like that. | ||
|
||
The list should of course be synced with the source, in this case the User Profile Application, at least once each month. The reason I am not using Graph is that birthday is not in the schema. | ||
|
||
![mapping birthday and hiredate](../scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/mapping1.png) | ||
|
||
**Prereq: Map SPS-Birthday and SPS-Hiredate to RefinableDate00/01 or similar** | ||
|
||
Once data is showing up in those RefinableDate properties you should be ready to create the list. | ||
Grab the script here . It will create a few Site Columns and a Content type on the site collection of your choosing. The list is then created, and the Content type added to the list. | ||
The Add-UserDataToList function will query the UPA for accounts and write the data we need to the list. | ||
|
||
Hit the Reindex site in the site collections Search and Offline Availability section for the site columns to be picked up by search. | ||
|
||
Map the crawled properties to a couple of RefinableDates. If possible it is recommended to make this mapping on the tenant level as it ensures that you can use them in your entire tenant. | ||
![mapping birthdaythisyear and hiredatethisyear](../scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/mapping2.png) | ||
Find the Content Type ID of the Content type created by the script. | ||
|
||
|
||
Add a Results web part, name it "Todays work anniversaries" | ||
|
||
Set the Query template to: | ||
|
||
*Contenttypeid:0x01009290F0FA40E7CB42B55D6D96F897262B\* RefinableDate12=Today* | ||
|
||
*(replace 0x01009290F0FA40E7CB42B55D6D96F897262B with the value for the your content type)* | ||
|
||
Add a Results web part, name it "Upcoming anniversaries (7 days)" | ||
|
||
Set the Query template to: | ||
|
||
*Contenttypeid:0x01009290F0FA40E7CB42B55D6D96F897262B\* RefinableDate12<{Today+7} AND RefinableDate12>{Today}* | ||
|
||
*(replace 0x01009290F0FA40E7CB42B55D6D96F897262B with the value for your content type)* | ||
|
||
|
||
|
||
Add the managed properties birthdayhiredateAccountOWSUSER, nextWorkAnniversaryInYearsOWSTNMBR, RefinableDate10, RefinableDate12 to the Selected Properties in both web parts. | ||
|
||
Enter Layout slots | ||
|
||
Change UserEmail to use the birthdayhiredateAccountOWSUSER property | ||
|
||
Change Date from Created to RefinableDate12 | ||
|
||
For both web parts you can select the People layout on "page 2" in the web part configuration. | ||
|
||
Set Secondary text to: | ||
|
||
{{{Title}}} has been with us {{{nextWorkAnniversaryInYearsOWSTNMBR}}} years | ||
|
||
(remember to click Use Handlebars expression) | ||
|
||
Set Tertiary text to: | ||
|
||
{{getDate (slot item @root.slots.Date) "MMMM-D"}} | ||
|
||
(remember to click Use Handlebars expression) | ||
|
||
Set the sorting on the Upcoming Anniversaries to RefinableDate12 asc | ||
|
||
Run the Add-UserDataToList function in a runbook or similar once a month and you should be done😊 Near the end of the year you might need to run is once per day. | ||
|
||
![final result](../scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/anniversaries.png) |
Binary file added
BIN
+14.8 KB
docs/scenarios/assets/Setup-Results-web-part-to-show-birthdays/BirthdayUPA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+33.2 KB
docs/scenarios/assets/Setup-Results-web-part-to-show-birthdays/RefinableDate00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.7 KB
docs/scenarios/assets/Setup-Results-web-part-to-show-birthdays/birthdays.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.6 KB
...tup-Results-web-part-to-show-work-anniversaries/BirthdayAndHiredateSyncList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+66.1 KB
...rios/assets/Setup-Results-web-part-to-show-work-anniversaries/anniversaries.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.9 KB
...scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/mapping1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.6 KB
...scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/mapping2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.8 KB
docs/scenarios/assets/Setup-Results-web-part-to-show-work-anniversaries/upa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.