diff --git a/backends/rest_client.js b/backends/rest_client.js index 51d25de6..23d45732 100644 --- a/backends/rest_client.js +++ b/backends/rest_client.js @@ -89,6 +89,15 @@ module.exports = class RESTClient { .join('&'); } + async get_value(doctype, name, fieldname) { + let url = this.protocol + '://' + path.join(this.server, `/api/resource/${frappe.slug(doctype)}/${name}/${fieldname}`); + let response = await frappe.fetch(url, { + method: 'GET', + headers: this.json_headers + }); + return (await response.json()).value; + } + init_type_map() { this.type_map = { 'Currency': true diff --git a/server/rest_api.js b/server/rest_api.js index 50e5a8c3..6996f49d 100644 --- a/server/rest_api.js +++ b/server/rest_api.js @@ -51,6 +51,12 @@ module.exports = { return response.json(doc.get_valid_dict()); })); + // get value + app.get('/api/resource/:doctype/:name/:fieldname', frappe.async_handler(async function(request, response) { + let value = await frappe.db.get_value(request.params.doctype, request.params.name, request.params.fieldname); + return response.json({value: value}); + })); + // delete app.delete('/api/resource/:doctype/:name', frappe.async_handler(async function(request, response) { let doc = await frappe.get_doc(request.params.doctype, request.params.name)