Custom dialog content save

I want to save data of a custom dialog box to database but dialog.save() isn’t working nor does the frm.save(). How to get data pushed to database on click of a custom save button in dialog box ?

Create new instance of Dialog box using:

var dialog = new frappe.ui.Dialog({});
dialog.set_primary_action(__("Label"), function(frm){
cur_frm.save() // if it's  you've defined your function in form function.
});

Also double check whether cur_frm global variable exist in the context where you’re trying to call cur_frm.save() function or not.

Detailed example for your ref:

var dialog = new frappe.ui.Dialog();
dialog.set_primary_action(__("Save"), function(frm){

  /* frm variable will hold you dialog box data. 
  you can set the dialog form data to cur_frm.doc instance using:
  */
cur_frm.doc[fieldname] = frm[fieldname];
// now save the cur_frm using cur_frm.save() function to sync the form with database.

cur_frm.save();

})

i have to bulk update the contents selected in dialog box. Although i am able to do so by your otion but the problem is,

Let say i have a button named “bulk update”. I can access it via every docnames like id1,id2,id3.

I opened id9 and clicked “bulk update” button and selected there to change field x and y of docname id1 and id3.
By your method, it is doing the thing but also updating the id9 as it is the first page where data is inserted from dialog(and then data is pushed on database). So along with id 1 and id3, id9 docname is also updated which i don’t want.

Any help will be appreciated