Create record then immediate bring up edit on that record

When you create a new record in a list, you pull up the new screen, enter your data, save it.  That creates the record in the table with that data.  the record ID does not exist until the record is slaved.

what i'd like to do is find a way to create a record (blank) and then immediately bring up the edit screen so i'm editing a record with an assigned ID..

Does that makes sense?

The goal is to be able to use the defined record id in the edit form.

July 19th, 2015 10:11pm

Hi,

I believe this could be done in many ways.

Here is the approach I would use :

1) Create a javascript file to insert a blank item in your list 

function createListItem(siteUrl) { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('Announcements'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreateInfo); oListItem.set_item('Title', 'My New Item!'); oListItem.set_item('Body', 'Hello World!'); oListItem.update(); clientContext.load(oListItem); clientContext.executeQueryAsync( Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed) ); } function onQuerySucceeded() { alert('Item created: ' + oListItem.get_id());

//This is where I would open a window with the EditForm of the previously created blank item } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }

Source : https://msdn.microsoft.com/en-us/library/office/jj163201.aspx

2) Create a new "Add item" button using a script editor WebPart with an event to trigger the createListItem function.

3) Inside the onQuerySucceeded Retrieve the ID and open the EditForm on your list :

Ex: http://yourSite/Lists/YourListName/Editform.aspx?ID=" + oListItem.get_id()

Regards

Samuel Levesque | http://sharepointerie.com | Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Free Windows Admin Tool Kit Click here and download it now
July 20th, 2015 1:42am

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

Other recent topics Other recent topics