Try ERPNext Buy Support Partners Foundation

Set values into child table

Although i write the following code nothing is entering into the child table…


the code snippet…

and it isn’t showing any error …can anyone help me …

@NAGENDRA_KOMMIREDDI

Add console.log() and debug what parameters are you sending as well as what response you get?

Can you explain what are trying to achieve?

where is detials field. If this is a field from your parent form then you have to iterate child table entries to set values in every row of the table.

e.g.

frappe.ui.form.on("Registration",{
	detials: function(frm) {
		$.each(frm.doc.tablefieldname || [], function(i, v) {
			frappe.model.set_value(v.doctype, v.name, "email", "xyz@gmail.com")
		})
	}
})

details is the name of the child table …


i want to set the values for the fields in child table
and the child table is and
sangram ji thank you for your reply

you mentioned detials in your code correct it and try again.

sry i can’t understood what you are saying can you please tell me with the help of a code …
thank you

Explain in details what are you trying? On which event you want to fill the field in a table?

After clicking the button at the top i want to fill the table
is there any function like that the cur_frm.set_value

So, after click on verify button, you want to fill table fields.

try this

frappe.ui.form.on("Registration",{
	verify: function(frm) {
		frappe.call({
			method: "frappe.client.get",
			args: {
				doctype: "User",
				filters: {"email":user}    //user is current user here
			},
			callback: function(r) {
				$.each(frm.doc.details || [], function(i, v) {
					frappe.model.set_value(v.doctype, v.name, "name1", r.message.full_name)
					frappe.model.set_value(v.doctype, v.name, "email", r.message.email)
					frappe.model.set_value(v.doctype, v.name, "phone", r.message.phone)
				})
				frm.refresh_field('details');
			}
		})
	}
})

I tried but i am not getting the values in the tables …Thank you …

What is Current_User?
Add console.log in callback and check response

e.g

callback: function(r) {
				console.log("response",r.message)

and check this in your browser console

but i am getting the field values for the above three functions…

Thanks i think now i got the solution…I will not forget your help…thank you so much…

sorry for troubling you again …but i want to modify it little bit the code i just write …
i want to store the different users in the same doctype but because of this code it just duplicating all the values whenever the verify button is clicked


Thank you for your reply once again

How you solve this problem… pls help me i’m also get this problem

what is your problem exactly ?
he is using a for each function which iterates each row so he will keep getting the same entry in every row. if thats was your question.

Hello, I have had the same error for months and today I have solved sending the array.

cur_frm.set_value(“field_value”, data.message);

Complete code:

frappe.call({
	method: "frappe.client.get_list",
	args: {
		doctype: "Doctype table childs",
		fields: ["*"],
		filters: [["parent", "=", "name register parent"],],
		parent: "Employee"
	},
	callback: function (data) {
		if(data && data.message) {
			cur_frm.set_value("education", data.message);
		}
	}
});
2 Likes

Hi ,
How you solve this problem… pls help me i’m also get this problem

Hi @smehata,
Check this out…

can you show your frappe.client.get method?