Need help in fetching data

Hi , @Nick , many thanks for the reply , yes of-course I did .

Please help ,

Thanks

@Nick . Sorry my mistake , instead of reloading and clearing the cache , I reloaded the page , now the page loads but the the script is not working , I had a look at the console no error but the script is not working .

Please guide me

Thanks

@Muthu
Please share script

1 Like

@Nick Thanks a lot for swift reply and for continued support , here is the script

frappe.ui.form.on("TC", "tcno", function(frm, cdt, cdn){
frappe.call({
       "method": "frappe.client.get_value",
        args: {
		doctype: "Item",
		fieldname: "cmill",
		filters: {
		name:["=", frm.doc.item_name]
			 }           			
	      },								
	      callback: function (data) {									
	      console.log(data);
          cur_frm.set_value("cmill", data.cmill);
				        }					
	     })

});

Please help
Thanks

1 Like

@Muthu
Script says when tcno field from TC form changes cmill of the Item record of the item (i.e. item_name field from tc form) is fetched. And output will be displayed in console.

Is this you want to achieve?

1 Like

Jquery is not able to reference to frm check if you have passed the frm to your function or use cur_frm instead.

Thanks, Makarand

1 Like

Thanks a ton for the reply @Nick , what I want is when the tcno field changes , it should fetch the cmill value of that item and put that in cmill field in the TC doctype , tcno is nothing but the item_code I have changed the name of that field to be tcno .

Please guide me ,

This script fetches something and puts that in the cmill field in TC doctype , but instead of putting the values it puts a text in the field

frappe.ui.form.on("TC", "tcno", function(frm, cdt, cdn){
frappe.call({
       "method": "frappe.client.get_value",
        args: {
		doctype: "Item",
		fieldname: "cmill",
		filters: {
		name:["=", frm.doc.item_name]
			 }           			
	      },								
	      callback: function (data) {									
	      console.log(data);
              cur_frm.set_value("cmill", data.message.cmill);
				        }					
	     })

});

Please guide me . Thanks

Thanks @makarand_b ,I corrected the code , now no error but it does not work . Could you guide me please

Thanks

Hi @Nick and @makarand_b . I altered the code , and this puts a text "object object " in the cmill field , and I had a look at the console , and I got this message

Object value at left was snapshotted when logged, value below was evaluated just now  

Could you guys please help me .

My script ,

frappe.ui.form.on("TC", "tcno", function(frm, cdt, cdn){
frappe.call({
       "method": "frappe.client.get_value",
        args: {
		doctype: "Item",
		fieldname: "cmill",
		filters: {
		name:["=", frm.doc.item_code]
			 }           			
	      },								
	      callback: function (data) {									
	      console.log(data);
              cur_frm.set_value("cmill", data.message);
				        }					
	     })

});

@Muthu it should be data.message.cmill

or check in your console what it throws for data.message.cmill

1 Like

Thanks for reply @shivkumar , I checked that already since data.message.cmill does not show any error but it simply is not working and does not set any value to the cmill field .

Please guide me

Thanks

@Muthu
So you have almost reached the destination.
Now if it is a field normal field in the Item doc (except table i.e child doc) put
data.message.cmill instead of data.message

1 Like

@Nick. Thanks for the reply , even @shivkumar suggested the same but for no reason it does not work .

Please guide

Thanks

@Muthu

Share console.log(data); output from console.

1 Like

Thanks for reply @nick , here is the output

Object value at left was snapshotted when logged, value below was evaluated just now
Object {message: Object}
    message
    :
    Object
    cmill
    :
    null
    __proto__
    :
    Object
    __proto__
    :
    Object
    __defineGetter__
    :
    __defineGetter__()
    __defineSetter__
    :
    __defineSetter__()
    __lookupGetter__
    :
    __lookupGetter__()
    __lookupSetter__
    :
    __lookupSetter__()
    constructor
    :
    Object()
    hasOwnProperty
    :
    hasOwnProperty()
    isPrototypeOf
    :
    isPrototypeOf()
    propertyIsEnumerable
    :
    propertyIsEnumerable()
    toLocaleString
    :
    toLocaleString()
    toString
    :
    toString()
    valueOf
    :
    valueOf()
    get __proto__
    :
    __proto__()
    set __proto__
    :
    __proto__()
    arguments
    :
    null
    caller
    :
    null
    length
    :
    1
    name
    :
    "set __proto__"
    __proto__
    :
    ()
    <function scope>

Kindly help

Thanks a ton @Nick , for solving my issue . Many thanks you are awesome .

1 Like

@Muthu
can you please share your solution?

@Muthu
could you please share your solution?

Hello @Muthu,

you can tried below code for fetching data.

frappe.ui.form.on(‘Linkedin API Configuration’, {
get_authentication_details: function(frm) {
console.log(“::::::yes::::::::::”, frm);
frappe.call({
method: /* Define Method path */
args: {
date: frappe.datetime.nowdate(),
},
callback: function(r) {
console.log(“::::::DONE::::::::::”);
}
});
}
});

Thanks.