#StackBounty: #development #sharepoint-addin #remote-event-receiver #office-365-developer #date properties.ItemEventProperties.AfterPro…

Bounty: 100

I have the following code inside my remote event receiver inside a SharePoint online team site, the remote event receiver is deployed inside azure web service:-

if (i["ProjectDateSinged"] != null && properties.ItemEventProperties.AfterProperties.ContainsKey("ProjectDateSinged") && properties.ItemEventProperties.AfterProperties["ProjectDateSinged"] != null)
DateTime currentpds = (DateTime)(i["ProjectDateSinged"]);
DateTime afterpds   = (DateTime.Parse(properties.ItemEventProperties.AfterProperties["ProjectDateSinged"].ToString()));
if (currentpds.Date != afterpds.Date)
    errormessage = errormessage + "You are not authorized to update DateSigned. ";

the code is to prevent users from updating a field named ProjectDateSinged… but currently the code is failing because i am getting the same date in different amounts. for example if i have an item with ProjectDateSinged = 15 July 2020, then the (DateTime)(i["ProjectDateSinged"]) will be equal to 15/07/2020 00:00:00 which is correct, while the (DateTime.Parse(properties.ItemEventProperties.AfterProperties["ProjectDateSinged"].ToString())) will be equal to 14/07/2020 23:00:00 which is one hour before the correct value, so the validation will always fail.. any advice on how i can fix this?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.