0

I am writing a remote event receiver for our online custom list, and the RER itself do some updates to the item been added/updated, where this is causing my RER to keep firing. so is there a way when i issue a Update() or SystemUpdate() inside my RER to prevent this update from firing additional RER?

Thanks

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.