You can check the value of beforeProperties and afterProperties of what you wanted to update, and if there was no difference, then you can break out of the method.
private static bool ShouldSecretBeUpdated(
IReadOnlyDictionary<string, object> beforeProperties,
IReadOnlyDictionary<string, object> afterProperties)
{
// If the property doesn't exist, then the secret should be updated
if (!beforeProperties.ContainsKey("field") || !afterProperties.ContainsKey("field"))
{
return true;
}
else
{
//if the property exists, not do the event receiver
return false;
}
}
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
// When new case is added or updated, this is the method that gets triggered
if (properties.EventType.Equals(SPRemoteEventType.ItemUpdated))
{
var afterProperties = properties.ItemEventProperties.AfterProperties;
var beforeProperties = properties.ItemEventProperties.BeforeProperties;
if (ShouldSecretBeUpdated(beforeProperties, afterProperties))
{
//do update event receiver
}
}
}
}
More references:
BR