Get Value client side script

What is the way to get a field value from another doctype as
frappe.db.get_value does not seem to work.
here is the code

items.forEach(function(row){
			if ((row.actual_qty - (row.qty + row.sal_reserved_qty)) < 0) {
				flag = 1;
				item_flag = row.item_code;
				is_stock_item = frappe.db.get_value('Item', row.item_code, 'is_stock_item')
				console.log(is_stock_item);
			}
		});

Any help would be appreciated

Hello,

When you are using get_value on the client-side, don’t forget that it returns a Promise object. You will have to catch the values using then or use async/await approach.

Check this link for more info: Server Calls (AJAX)

Regards,

Ivan

an example that work for me:

frappe.db.get_value("Item Price", {
			"item_code": d.item_code,
			"price_list": pricelist
		}, ['price_list_rate', 'ek_discount'], function (value) {
			if (typeof value.ek_discount !== "undefined") {
				d.ek_discount = value.ek_discount;
			}
		});

Through this link i was able to appropriate change my code and get a working solution

frappe.call({
	method: 'frappe.client.get_value',
	args: {
	doctype: 'Item',
	name: row.item_code,
	fieldname: 'is_stock_item'
	},
       callback: function(r){						
           is_stock_item = r.message.is_stock_item;
           console.log(is_stock_item);
	}
});
1 Like