Save doc after using frappe.model.make_new_doc_and_get_name

Hi, Actually I need some help on saving the doc after using the topic mentioned method, In my case I have a dialogue that stores values inline and saves the doc on submit. So probably i cannot use frm.doc.save().

@mzain share your code, your question is not clear

@rmehta, Actually I am working on to create a new item inline with the help of dialogue. So let suppose while selecting an item in ‘Sales Order Item’ I want to create a new item, than unfortunately we have to navigate the new item page. So this inline feature will help us in creating new item quickly.

So for this I used frappe.model.make_new_doc_and_get_name to create a new doc, But I was unable to save. Fortunately I found out the solution i.e

frappe.call({
	method: "frappe.client.insert",
		args: {
			doc: item
		}									
	});

Are you planning to contribute this back to the product?

Yeah hopefully !!!

1 Like

Share your code via a pull-request, we will be happy to help / guide.

i know its been a long time but i am stuck at the same place you were, i am trying to get a way to create and then save a record i use but instead of routing to it so i can manually save i wanted to be able to insert it automatically, any help ?

frappe.ui.form.on("trial", {
	refresh: function(frm) {
		frm.add_custom_button(__("Update"),
			function() {   
						
				
					tn = frappe.model.make_new_doc_and_get_name("Item");
					locals["Item"][tn].item_code = frm.doc.gen_name;
					locals["Item"][tn].item_group = "Control";
						frappe.set_route("Form", "Item", tn);
			});
	}
});

Hello @Mohammed_ElKadee, did you resolve this issue?
Regards.

I am sorry but I stopped using erpnext a long time ago and I don’t have any record of it. Wish you all the best