Controller responsible for the operations and data of the doctypes' meta fields.
To get the number of documents based on a filter, if any.
GetDocCountParams
property | type | required | description |
doctype | string | yes | The target doctype |
filters |
| no | Filters based on |
number
async-await
const docCount = await renovation.meta.getDocCount("User", {name: ["LIKE", validUser]});​if (docCount.success) {// Number of docs: 3console.log("Number of docs: ", docCount.data);} else {console.error("Error:", docCount.error);}
Classic Promise
renovation.meta.getDocCount({doctype: "User",filters: { name: ["LIKE", "test@abc.com"] }}).then(docCount => {if (docCount.success) {console.log("Number of docs: ", docCount.data);} else {console.error("Error:", docCount.error);}});
HTTP code:
404
type:
NotFoundError
cause: DocType does not exist
suggestion: Make sure the queried DocType is input correctly or create the required DocType
To get a doctype's meta. Meta of a doctype is the details about a doctype including but not limited to, DocFields, permissions, etc..
This is useful especially for building the UI based on the fields and properties of a DocType.
GetDocMetaParams
property | type | required | description |
doctype | string | yes | The target doctype |
DocType
DocType
contains an Indexed Property so the properties are available as they are defined in the backend.
async-await
const docMeta = await renovationInstance.meta.getDocMeta({doctype: "Renovation Review"});​if (docMeta.success) {console.log("Doc Meta: ", docMeta.data);} else {console.error("Error:", docMeta.error);}
Classic Promise
renovationInstance.meta.getDocMeta({doctype: "Renovation Review"}).then(docMeta => {if (docMeta.success) {console.log("Doc Meta", docMeta.data);} else {console.error("Error:", docMeta.error);}});
{"allowCopy": false,"allowEventsInTimeline": 0,"allowGuestToView": false,"allowImport": true,"allowRename": false,"app": null,"autoname": "naming_series:","beta": false,"color": null,"colour": null,"creation": "2013-06-24 19:29:05","custom": false,"defaultPrintFormat": "","description": null,......}
HTTP code:
404
type:
NotFoundError
cause: DocType does not exist
suggestion: Make sure the queried DocType is input correctly or create the required DocType
To get the document's information defined by DocInfo
of a certain document of a certain doctypes.
GetDocInfoParams
property | type | required | description |
doctype | string | yes | The target doctype |
docname | string | yes | The target document |
DocInfo
async-await
const docInfo = await renovationInstance.meta.getDocInfo({doctype: "User",docname: "test@abc.com"});​if (docInfo.success) {console.log("Doc Info: ", docInfo.data);} else {console.error("Error:", docInfo.error);}
Classic Promise
renovation.meta.getDocInfo({doctype: "User",docname: "test@abc.com"}).then(docInfo => {if (docInfo.success) {console.log("Doc Info: ", docInfo.data);} else {console.error("Error:", docInfo.error);}});
{"communications": [],"assignments": [],"rating": 0,"attachments": [{"file_name": "picture_1.jpeg","file_url": "/private/files/picture_1.jpeg","name": "8e291854f4","is_private": 1,"complete_url": "http://back-end-url.net/private/files/picture_1.jpeg"}],"versions": [{"owner": "test-user@abc.com","creation": "2019-05-14 01:03:57.421594","data": "{\n \"comment\": \"added <a href='/private/files/picture_1.jpeg' target='_blank'>picture_1.jpeg</a> <i class=\\\"fa fa-lock text-warning\\\"></i>\", \n \"comment_type\": \"Attachment\"\n}","name": "294e84239e"}],"shared": [],"views": [],"permissions": {"recursive_delete": 0,"read": 1,"create": 1,"share": 1,"submit": 0,"if_owner": {},"write": 1,"amend": 0,"report": 1,"export": 1,"set_user_permissions": 0,"print": 1,"import": 1,"email": 1,"cancel": 0,"delete": 1},"total_comments": 0}
HTTP code:
404
type:
NotFoundError
cause: DocType does not exist
suggestion: Make sure the queried DocType is input correctly or create the required DocType
HTTP code:
404
type:
NotFoundError
cause: Docname does not exist
suggestion: Make sure the queried document name is correct or create the required document
HTTP code:
404
type:
NotFoundError
cause: DocInfo not found
suggestion: Make sure the document has DocInfo
To get the label to be used on a field
GetFieldLabelParams
property | type | required | description |
doctype | string | yes | The target doctype |
fieldname | string | yes | The target within the doctype |
Promise<string>
async-await
const fieldLabel = await renovationInstance.meta.getFieldLabel({doctype: "Renovation Review",fieldname: "reviewed_by"});​// Field label: Reviewed Byconsole.log("Field label: ", fieldLabel);
Classic Promise
renovationInstance.meta.getFieldLabel({doctype: "Renovation Review",fieldname: "reviewed_by"}).then(fieldLabel => {// Field label: Renovation Reviewconsole.log("Field label: ", fieldLabel);});
HTTP code:
404
type:
NotFoundError
cause: DocType does not exist
suggestion: Make sure the queried DocType is input correctly or create the required DocType
To get the report meta of Renovation Report
doctype.
GetReportMetaParams
property | type | required | description |
report | string | yes | The name of the |
ReportMeta
async-await
const reportMeta = await renovationInstance.meta.getReportMeta({report: "TEST"});​if (reportMeta.success) {console.log("Report Meta ", reportMeta.data);} else {console.error("Error:", reportMeta.error);}
Classic Promise
renovationInstance.meta.getReportMeta({report: "TEST"}).then(reportMeta => {if (reportMeta.success) {console.log("Report Meta ", reportMeta.data);} else {console.error("Error:", reportMeta.error);}});
{"doctype": "Renovation Report","name": "TEST","owner": "test@abc.com","creation": "2020-02-29 14:40:58.218626","modified": "2020-03-22 18:30:17.645715","modified_by": "test@abc.com","parent": null,"parentfield": null,"parenttype": null,"idx": 0,"docstatus": 0,"report": "TEST","filters": [{"name": "2da4c94949","owner": "test@abc.com","creation": "2020-02-29 14:40:58.218626","modified": "2020-03-22 18:30:17.645715","modified_by": "test@abc.com","parent": "TEST","parentfield": "filters","parenttype": "Renovation Report","idx": 1,"docstatus": 0,"label": "Email","fieldname": "email","reqd": 0,"fieldtype": "Link","options": null,"default_value": null,"doctype": "Renovation Report Filter"}]}
HTTP code:
404
type:
NotFoundError
cause: The target report does not exist
suggestion: Make sure the name is correct or create the report