Submit form without closing

Hello,

While in New Form and Edit, is it possible to create a button and on click, have it submit/save the form but keep the same form open (without closing it)?

Thank you!

Hello @ParAvion,

Please find the answer in this post:

@mnikitina thanks but i cannot seem to get this working.

Here's my code:

fd.spSaved(function(result) {
var listId = fd.spFormCtx.ListAttributes.Id;
var itemId = result.Id;

//replace "https://mysite.sharepoint.com/sites/ProjectManagement" with path to your site
//PageType=6 means Edit Form
result.RedirectUrl =
    "https://mysite.sharepoint.com/sites/ProjectManagement/_layouts/15/listedit.aspx?PageType=6&ListId="
    + listId + "&ID=" + itemId;

});

@ParAvion,

There is a typo in your code. It should be 'form' in the page name:
_layouts/15/listform.aspx?PageType=6&ListId

Please use the following code.

fd.spSaved(function(result) {
    var listId = fd.spFormCtx.ListAttributes.Id;
    var itemId = result.Id;

    //replace "https://domain.sharepoint.com/sites/sitename/subsite" with path to your site
    //PageType=6 means Edit Form
    result.RedirectUrl =
        "https://mysite.sharepoint.com/sites/ProjectManagement/_layouts/15/listform.aspx?PageType=6&ListId="
        + listId + "&ID=" + itemId;
});

Should i leave "subsite" in the path or change it? I don't have a subsite for this list. Thanks for your help!

@ParAvion,

Sorry, my mistake. Yes remove it.

I am trying to get the Id and title of the new form item and concat but i am not getting title it gives null but i am getting the right id. below is the code

fd.spSaved(function(result){
var Id= result.Id; // returns correct item id
var title = fd.field('Title').value; // returning null
var title = result.Title;//// returning null
});

@ShantiBhattarai,

You can't get the field value under spSaved event. It occurs after the form is submitted, and it only returns item ID and RedirectUrl.

Please find more information about the events here.

Could you please provide more details about what you want to develop so I could suggest something. Why do you need to concat item ID and Title?

i was trying to create a primary key column with two column concat since title can have duplicate values. I can do this from flow but i want to achieve this without using flow if possible. Thank you.

Hello @ShantiBhattarai,

For this, you can simply create a calculated column.
image

And use the following expression in Additional Column Settings >> Formula:

=[Title]&" "&[ID]

1 Like

this is for one field but if i want to pass lot of fields from form is there a wayaround?

what i want to achieve is when new form is saved then open another new form passing data from this new form or be ale to create multiple items in the same new form with certain header retained for same session for repeated fields and add multiple records without closing form

@ShantiBhattarai,

I'm not sure I understood you correctly.

At some stage of filling out of a New form, you can redirect a user to the Edit form. For example, you can add a Next button. In the Edit form, you will be able to get the current item ID alongside field values.

Please see Redirect to Edit Form article for the code example.

If this does not meet your needs, please provide more information on what you want to achieve.

what i want is after new item is created don't close the form and retain few fields value to create another new item untill its closed. There are several repeating fields which needs to be pre-filled from the prevoius session until it is closed.

@ShantiBhattarai,

If you need to create new items using current item ID, you can redirect user to edit form after new item is submitted. In the Edit Frm you can get all fields and item ID and create new items using PNP JS. You can find a good code example in this post: