Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

How to Open Edit Form Right After Creation of an Item in SharePoint

, 27 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
How to open an edit form of an item right after its creation

In this article, I would like to demonstrate how to open an edit form of an item right after its creation. This feature is very useful if you have related items filtered by the currently selected item on the form. As you may have noticed, you cannot edit related items on a new form because the parent item has not been created and its ID is not defined yet, so, other list items or documents cannot be linked to it.

Due to this issue, to create an item with connected child items, users have to create a parent item first, save it and find it in the list, open its edit form and start editing the related items. Quite difficult, isn't it?

In SharePoint Forms Designer 2.7.11 we have implemented functionality that helps you to redirect users to any URL including edit form of an item right after its creation and inject ID of the currently created item into the link address.

Please note: This functionality works only in forms opened in full page, not in dialogs. In SharePoint 2013, all forms are opened in full page by default but in SharePoint 2010, you have to change this option in the following way: List Settings ? Advanced Settings ? Launch forms in a dialog. Set this option in 'No'.

Now, navigate to the list where you wish to configure redirection, open Forms Designer and choose a new form. Add the following JavaScript into JS-editor:

fd.onsubmit(function() {
  var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 
  'FDRedirectWithID', 'fd_Item_Edit.aspx?ID=');
  fd.sourceFormParam(uri);
  return true;
});

As you can see, I used new JavaScript functions here:

  • setUrlParam(url, key, value) - Adds or updates query parameter in provided URL with a specified value and returns a new URL.
  • Url - source URL-string.
  • Key - name of query string parameter
  • Value - new value of query parameter

sourceFormParam(value): Gets or sets 'Source' query parameter of the URL which is contained in action attribute of the form. Source parameter contains URL of the page where users will be redirected after the submission of the form. If value is not specified, the function returns the current value of 'Source' parameter.

In my example, users will be redirected after submission to the same page but with additional query parameter 'FDRedirectWithID'. If this query parameter is not empty, Forms Designer gets its value, appends ID of the last item created by the current user and redirects to the generated URL. In my case, users will be redirected to 'fd_Item_Edit.aspx' form. You have to replace the name of the form with your own value. You can find it at the left bottom corner of Forms Designer.

SharePoint form name

If you have any questions, please leave them here. Thank you.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dmitriy Kozlov
Technical Lead Plumsail
Russian Federation Russian Federation
Expert in SharePoint
The leader of SharePoint Forms Designer Team: http://spform.com
Co-founder of Plumsail: http://plumsail.com
My blog: http://formsdesigner.blogspot.com
Follow on   Twitter   LinkedIn

Comments and Discussions

 
QuestionReferenceError: fd is not defined PinmemberMember 105084367-Jan-14 2:17 
GeneralMy vote of 4 PinmemberMBSMBS6-Oct-13 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150305.1 | Last Updated 27 Oct 2013
Article Copyright 2013 by Dmitriy Kozlov
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid