Sanjeev Gautam
Sanjeev Gautam

Reputation: 363

get all employee anniversary for the current month from user profile + SP2013

I have a requirement in Sp2013 on premise. I need to pull Anniversary for all the employee for the current month. I have code that pull data for the current user. I need help for all the users, who anniversary belong to current month. Any help is appreciated.

var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties"; 

$.ajax({  

    url: url,
    type: "GET",

    contentType: "application/json;odata=nometadata",  
    headers: { Accept: "application/json;odata=verbose" },  
    success: function (data) {  
        try {  
            //Get properties from user profile Json response  
            userDisplayName = data.d.DisplayName;  
            AccountName = data.d.AccountName;

Upvotes: 0

Views: 1285

Answers (2)

ssspfx
ssspfx

Reputation: 103

You need to use a Refiner property like date or string. And go with rest search api call.

  1. Map People:BirthDate or SPS-Birthday according to the custom or Sharepoint OOB property.
  2. Anniversary has year associated with it. But birthday has date month no year.
  3. Apply filter accordingly to get relevant results. Refer to the below for sample: https://joranmarkx.wordpress.com/2013/10/02/show-upcomming-birthdays-based-on-sharepoint-2013-user-profiles-with-search-office365/

Upvotes: 0

Sigar Dave
Sigar Dave

Reputation: 2664

CSOM will provides method for the Per user. So in your case if you want to get the anniversary of each user then you need to first get all the users available in a site collection and then iterate through them to get the user profile of it and get the anniversary field. @vaibhav suggested there is an example of how to implement this.

Look for the most upvoted answer

Thanks

Upvotes: 1

Related Questions