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