Dynamic Validation with MVC

Vote:
 

Hi,

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.

Thanks,

Mark

#113038
Nov 11, 2014 12:28
Vote:
 
#113040
Nov 11, 2014 13:38
Vote:
 

Hi Linus,

That does look interesting but I'm not sure how I would implement that for my scenario.

Thanks,

Mark

#113046
Nov 11, 2014 16:08
Vote:
 

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);

#113096
Nov 13, 2014 8:20
Vote:
 

Thanks Linus that was exactly what I needed!

Cheers,

Mark

#113117
Nov 13, 2014 11:40
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.