NewForm.aspx redirect after save

Hi

On my SC site in Quick Links area I created link to new calendar form.

I would like to redirect back to this form after the item is created.

Usually I use "&Source" parameter to redirec however in this case it doesn't work form me and I am not sure why.

It works for my InfoPath forms but not for this calendar form.

Therefore I decieded to use other solution with custom save button.



<input type="button" value="Form Action" name="btnFormAction" onclick="javascript:{ddwrt:GenFireServerEvent('__commit;myFunc();__redirect={http://intranet/HR/Holiday/Lists/Calendar/NewForm.aspx?RootFolder_x003D_}')}" />

This is working fine, however I also attached validation in PreSaveAction() function which is now bypassed.

I tried to add extra javascript function like:

onclick="javascript:myFunc();{ddwrt:GenFireServerEvent('__commit;myFunc();__redirect={http://intranet/HR/Holiday/Lists/Calendar/NewForm.aspx?RootFolder_x003D_}')}"

which execute my validation in "myFunc()" function. However even if I include "return false;" in "myFunc()" sharepoint executes save action anyway.

I cannot use InfoPath as this is a calendar form.

Is there a way to introduce rediraction in PreSaveAction() function? I tried window.location but it doesn't work if PreSaveAction() returns true.

Thanks in advance

Marcin

September 14th, 2012 5:59pm

Hi ,

I understand that you want to redirect to new form page after save the list item. You can use javascript to  achieve this redirect.

Here is an sessvars.js file available, you can use this .js file to the code:

<script type="text/javascript" src="/test/English/Javascript/sessvars.js"></script>

<script type="text/javascript">

var targetUrl = sessvars.targetUrl;

if(targetUrl!=undefined){

  sessvars.$.clearMem();

  window.location.href = targetUrl;

}

</script>

For more detailed information ,please refer to these sites:

Redirect from NewForm to EditForm or custom page: http://sharepointjavascript.wordpress.com/2009/09/04/redirect-from-newform-to-editform-or-custom-page/

Redirect on NewForm and EditForm another method: http://sharepointjavascript.wordpress.com/2009/11/21/redirect-on-newform-and-editform-another-method/#viewSource

Thanks,

Entan Ming

Free Windows Admin Tool Kit Click here and download it now
September 17th, 2012 11:21am

How about this :

$(document).ready(function () {

        var redirectUrl = _spPageContextInfo.siteAbsoluteUrl + "/Lists/ListName/PageName.aspx?ID=1";
        WPQ2FormCtx.RedirectInfo.redirectUrl = redirectUrl;    });

January 31st, 2015 12:04am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics