After a document is uploaded, the 'Edit Properties' window is displayed.

Due to restrictions with integration with other applications, the 'Edit Properties' window must be displayed, but I need to immediately close it without any user input.

I'm using C# to run some workflows immediately after a document is uploaded, so it will show that the SharePoint system has made changes, so if a user clicks 'Save' on that 'Edit Properties' window, it will throw an error.

Could someone point me in the right direction of where to start? Is there a way to just click the 'Cancel' button with code?

Edit: Per advice below, I have tried to add a javascript snippet (I confused jquery with javascript...) [window.location.href = "http://test.com";] but it redirects every time a user navigates to the Edit Properties window. My intention was only for it to close the window upon upload. Users should be able to access it otherwise. Any thoughts?

1 Answer 1


You could create a custom EditForm.aspx in SharePoint Designer. This EditForm will have some javascript behind it that can "Click" the Cancel button with jquery using .click(), or have the user redirected to a page using window.location.href

  • 2
    and without jQuery: document.querySelector( [SELECTOR] ).click() May 25, 2017 at 17:04
  • yes! I do not like using jquery if I don't have to.
    – Mike
    May 25, 2017 at 17:04
  • Hi Danny, Mike - Thank you for your replies! I have looked into it an added that snippet of code, but it closes the window every time I open it (I guess that is to be expected, though). I was hoping to only close it that one time on document upload. Is there a different place (workflow code, EditForm.aspx) that would be a better candidate?
    – Cat
    May 25, 2017 at 17:12
  • 1
    try adding it like this between the script tags: (function() { if (document.referrer === 'http://[URL]/_layouts/15/Upload.aspx?List=[GUID]' ) { window.location.href = "http://[URL].com"; })()
    – Mike
    May 25, 2017 at 17:46
  • 1
    If it works manually with one click, then maybe wrap the .click() in a setTimeout May 25, 2017 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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