We have a situation where we provide a review date field on pages which is required and must be within a certain date range, greater than today and less than 12 months from now. We use this to remind users to review their content and we remind the users via a scheduled job that checks for any review dates that are in the past. When we send the reminders we also set another boolean property on the page to indicate that the reminder has been sent so that users only get one reminder.
Now when we are setting the boolean flag we have to save the page but we want the review date to remain the same until the user has reviewed and edited the page. As a result of the validation we have in place the page can't be saved after setting the boolean flag (in the job) as the date is in the past.
Is there a way of temporarily marking the page as valid or preventing the validation at this point in the scheduled job and then re-enabling the validation once this step is complete? Is there another approach that would work better.
Have you tried using a ValidationAttribute? I have a sample written here:
That does look interesting but I'm not sure how I would implement that for my scenario.
After reading your post again, I'm wondering if you have tried the SkipValidation flag when saving?
var contentLink = _myContentRepositoryInstance.Save(content, SaveAction.Publish | SaveAction.SkipValidation);
Thanks Linus that was exactly what I needed!