.meta

Controller responsible for the operations and data of the doctypes' meta fields.

.getDocCount()

To get the number of documents based on a filter, if any.

Input

GetDocCountParams

property

type

required

description

doctype

string

yes

The target doctype

filters

DBFilter

no

Filters based on DBFilter interface

Output

number

Example

async-await

const docCount = await renovation.meta.getDocCount("User", {
name: ["LIKE", validUser]
});
if (docCount.success) {
// Number of docs: 3
console.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);
}
});

Possible Errors

Doctype Does Not Exist

HTTP code: 404

type: NotFoundError

cause: DocType does not exist

suggestion: Make sure the queried DocType is input correctly or create the required DocType

.getDocMeta() ★

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.

Input

GetDocMetaParams

property

type

required

description

doctype

string

yes

The target doctype

Output

DocType

DocType contains an Indexed Property so the properties are available as they are defined in the backend.

Example

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);
}
});

Sample Response

{
"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,
......
}

Possible Errors

Doctype Does Not Exist

HTTP code: 404

type: NotFoundError

cause: DocType does not exist

suggestion: Make sure the queried DocType is input correctly or create the required DocType

.getDocInfo()

To get the document's information defined by DocInfo of a certain document of a certain doctypes.

Input

GetDocInfoParams

property

type

required

description

doctype

string

yes

The target doctype

docname

string

yes

The target document

Output

DocInfo

Example

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);
}
});

Sample Response

{
"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
}

Possible Errors

Doctype Does Not Exist

HTTP code: 404

type: NotFoundError

cause: DocType does not exist

suggestion: Make sure the queried DocType is input correctly or create the required DocType

Docname Does Not Exist

HTTP code: 404

type: NotFoundError

cause: Docname does not exist

suggestion: Make sure the queried document name is correct or create the required document

DocInfo Not Found

HTTP code: 404

type: NotFoundError

cause: DocInfo not found

suggestion: Make sure the document has DocInfo

.getFieldLabel()

To get the label to be used on a field

Input

GetFieldLabelParams

property

type

required

description

doctype

string

yes

The target doctype

fieldname

string

yes

The target within the doctype

Output*

Promise<string>

Example

async-await

const fieldLabel = await renovationInstance.meta.getFieldLabel({
doctype: "Renovation Review",
fieldname: "reviewed_by"
});
// Field label: Reviewed By
console.log("Field label: ", fieldLabel);

Classic Promise

renovationInstance.meta
.getFieldLabel({
doctype: "Renovation Review",
fieldname: "reviewed_by"
})
.then(fieldLabel => {
// Field label: Renovation Review
console.log("Field label: ", fieldLabel);
});

Possible Errors

Doctype Does Not Exist

HTTP code: 404

type: NotFoundError

cause: DocType does not exist

suggestion: Make sure the queried DocType is input correctly or create the required DocType

.getReportMeta()

To get the report meta of Renovation Report doctype.

Input

GetReportMetaParams

property

type

required

description

report

string

yes

The name of the Renovation Report report

Output*

ReportMeta

Example

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);
}
});

Sample Response

{
"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"
}
]
}

Possible Errors

Renovation Report does not exist

HTTP code: 404

type: NotFoundError

cause: The target report does not exist

suggestion: Make sure the name is correct or create the report