Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a custom list form in SharePoint Online 2013 which after validating using the PreSave() function displays a modal dialog giving the user a choice of two outcomes. This works fine and the user is returned to the lists's AllItems.aspx page.

What I would like to do is return the user to the site's Home Page and have tried to achieve this by using the following code:

WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(saveButtonName, "", true, "", "https://[mydomain].sharepoint.com/sites/dev/SitePages/Home%20Page.aspx", false, true));

The url is valid, and redirects correctly, but I am returned with a SharePoint error:

Sorry, something went wrong

This Page has been modified since you opened it. You must open the page again.

Is there a way to overcome this issue or should I be using another way to skin this particular cat?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

How about relying on the Source querystring instead?

Here is a crude example of what I'm getting at:

(function(w) {
  w.PreSaveAction = function() {
    return w.confirm('Have you been working on it?');
  };

  var source = '/sites/dev/SitePages/Home%20Page.aspx';
  var loc = w.location;
  var s = loc.search;
  if (s.indexOf(source) >= 0) return;

  loc.href = loc.href.replace(/\?.*/, '') + '?' + s.replace(/\?/, '').split('&').filter(function(q) { 
    return !q.match(/^source/i); 
  }).join('&') + '&Source=' + source;
})(window);
share|improve this answer
    
Thanks for the suggestions. I'm currently focussed elsewhere but will give your suggestion a try in a few days –  Fairfield Feb 18 at 23:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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