Frappe.client.get_value not working properly

Hi All,
I have added a custom script for fetching a field value in Purchase Invoice with frappe.client.get_value. It is working sometime or throws following error:
Unable to handle success response
desk.min.js?ver=1513603063.0:1482 TypeError: Cannot read property ‘kyc_document’ of undefined
at Object.callback (eval at setup (form.min.js?ver=1513603063.0:2616), :72:24)
at Object.callback [as success_callback] (desk.min.js?ver=1513603063.0:1354)
at _ (desk.min.js?ver=1513603063.0:1378)
at Object. (desk.min.js?ver=1513603063.0:1478)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at z (jquery.min.js:4)
at XMLHttpRequest. (jquery.min.js:4)
(anonymous) @ desk.min.js?ver=1513603063.0:1482

ERPNext: v9.0.4

double check custom fields

the ‘kyc_document’, you mean??
The field is present, success if it has value, false when null.

share ur code

frappe.call({
method:“frappe.client.get_value”,
args: {
doctype:“Supplier”,
filters: {
supplier_name: cur_frm.doc.supplier
},
fieldname:[“kyc_document”]
},
callback: function(r) {
if(r.message.kyc_document == null)
{
frappe.msgprint(“Kindly attach the KYC documents”);
}

i think if kyc_document is null you’ll not have it in r.message …log it and double check

Can you suggest a work around for this, please.

try console.log(r.message) and check the result in callback

ReferenceError: r is not defined :expressionless:

you’re missing a } after doctype:“Supplier”, double check