@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")
})
}
})
1 Like
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
Murugan
January 10, 2018, 1:42pm
14
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);
}
}
});
4 Likes
smehata
October 22, 2019, 9:03am
17
Hi ,
How you solve this problem… pls help me i’m also get this problem
Saditi
November 1, 2019, 7:50am
18
Hi @smehata ,
Check this out…
Just a thought, nice code snippet, but is a server-side code required? What if this API call was used:
frappe.call({
method:"frappe.client.get_list",
args:{
doctype:"Item Attribute Value",
filters: [
["supplier","=", frm.doc.supplier]
],
fields: ["parent"],
parent: "Supplier"
},
callback: function (response) {
/* see above */
}
});
So I was able to try this and get the desired effect, however I did this on a button click:
Python:
import frappe
@frappe.whitelist()
def get_items_supplied(supplier):
items = frappe.get_all(
"Item Supplier",
{"supplier":supplier},"parent",
as_dict=1)
return items
Javascript
fetch_supplied_items is my button field.
frappe.ui.form.on("Purchase Receipt",{
"fetch_supplied_items": function(frm, cdt, cdn){
frappe.call({
method:"randomcode…
can you show your frappe.client.get method?
wale
January 8, 2021, 11:09am
20
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) {
cur_frm.clear_table("details");
for (var i =0; i < r.message.length; i++){
frappe.model.add_child(cur_frm.doc, "Regs Details", "details");
}
$.each(frm.doc.details || [], function(i, v) {
frappe.model.set_value(v.doctype, v.name, "name1", r.message[i].full_name)
frappe.model.set_value(v.doctype, v.name, "email", r.message[i].email)
frappe.model.set_value(v.doctype, v.name, "phone", r.message[i].phone)
})
frm.refresh_field('details');
}
})
}
})
If you need to update a field in Child table simple AJAX call
frappe.call({
“method”: “frappe.client.set_value”,
“args”: {
“doctype”: child_table_name,
“name”: name_of_row,
“fieldname”: {
“field_name1”:“value1”,
“field_name2”:"value2
}
}
})
1 Like