Renovation
Search…
.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
1
const docCount = await renovation.meta.getDocCount("User", {
2
name: ["LIKE", validUser]
3
});
4
​
5
if (docCount.success) {
6
// Number of docs: 3
7
console.log("Number of docs: ", docCount.data);
8
} else {
9
console.error("Error:", docCount.error);
10
}
Copied!
Classic Promise
1
renovation.meta
2
.getDocCount({
3
doctype: "User",
4
filters: { name: ["LIKE", "[email protected]"] }
5
})
6
.then(docCount => {
7
if (docCount.success) {
8
console.log("Number of docs: ", docCount.data);
9
} else {
10
console.error("Error:", docCount.error);
11
}
12
});
Copied!

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
1
const docMeta = await renovationInstance.meta.getDocMeta({
2
doctype: "Renovation Review"
3
});
4
​
5
if (docMeta.success) {
6
console.log("Doc Meta: ", docMeta.data);
7
} else {
8
console.error("Error:", docMeta.error);
9
}
Copied!
Classic Promise
1
renovationInstance.meta
2
.getDocMeta({
3
doctype: "Renovation Review"
4
})
5
.then(docMeta => {
6
if (docMeta.success) {
7
console.log("Doc Meta", docMeta.data);
8
} else {
9
console.error("Error:", docMeta.error);
10
}
11
});
Copied!

Sample Response

1
{
2
"allowCopy": false,
3
"allowEventsInTimeline": 0,
4
"allowGuestToView": false,
5
"allowImport": true,
6
"allowRename": false,
7
"app": null,
8
"autoname": "naming_series:",
9
"beta": false,
10
"color": null,
11
"colour": null,
12
"creation": "2013-06-24 19:29:05",
13
"custom": false,
14
"defaultPrintFormat": "",
15
"description": null,
16
......
17
}
Copied!

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
1
const docInfo = await renovationInstance.meta.getDocInfo({
2
doctype: "User",
3
docname: "[email protected]"
4
});
5
​
6
if (docInfo.success) {
7
console.log("Doc Info: ", docInfo.data);
8
} else {
9
console.error("Error:", docInfo.error);
10
}
Copied!
Classic Promise
1
renovation.meta
2
.getDocInfo({
3
doctype: "User",
4
docname: "[email protected]"
5
})
6
.then(docInfo => {
7
if (docInfo.success) {
8
console.log("Doc Info: ", docInfo.data);
9
} else {
10
console.error("Error:", docInfo.error);
11
}
12
});
Copied!

Sample Response

1
{
2
"communications": [],
3
"assignments": [],
4
"rating": 0,
5
"attachments": [
6
{
7
"file_name": "picture_1.jpeg",
8
"file_url": "/private/files/picture_1.jpeg",
9
"name": "8e291854f4",
10
"is_private": 1,
11
"complete_url": "http://back-end-url.net/private/files/picture_1.jpeg"
12
}
13
],
14
"versions": [
15
{
16
"owner": "[email protected]",
17
"creation": "2019-05-14 01:03:57.421594",
18
"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}",
19
"name": "294e84239e"
20
}
21
],
22
"shared": [],
23
"views": [],
24
"permissions": {
25
"recursive_delete": 0,
26
"read": 1,
27
"create": 1,
28
"share": 1,
29
"submit": 0,
30
"if_owner": {},
31
"write": 1,
32
"amend": 0,
33
"report": 1,
34
"export": 1,
35
"set_user_permissions": 0,
36
"print": 1,
37
"import": 1,
38
"email": 1,
39
"cancel": 0,
40
"delete": 1
41
},
42
"total_comments": 0
43
}
Copied!

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
1
const fieldLabel = await renovationInstance.meta.getFieldLabel({
2
doctype: "Renovation Review",
3
fieldname: "reviewed_by"
4
});
5
​
6
// Field label: Reviewed By
7
console.log("Field label: ", fieldLabel);
Copied!
Classic Promise
1
renovationInstance.meta
2
.getFieldLabel({
3
doctype: "Renovation Review",
4
fieldname: "reviewed_by"
5
})
6
.then(fieldLabel => {
7
// Field label: Renovation Review
8
console.log("Field label: ", fieldLabel);
9
});
Copied!

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
1
const reportMeta = await renovationInstance.meta.getReportMeta({
2
report: "TEST"
3
});
4
​
5
if (reportMeta.success) {
6
console.log("Report Meta ", reportMeta.data);
7
} else {
8
console.error("Error:", reportMeta.error);
9
}
Copied!
Classic Promise
1
renovationInstance.meta
2
.getReportMeta({
3
report: "TEST"
4
})
5
.then(reportMeta => {
6
if (reportMeta.success) {
7
console.log("Report Meta ", reportMeta.data);
8
} else {
9
console.error("Error:", reportMeta.error);
10
}
11
});
Copied!

Sample Response

1
{
2
"doctype": "Renovation Report",
3
"name": "TEST",
4
"owner": "[email protected]",
5
"creation": "2020-02-29 14:40:58.218626",
6
"modified": "2020-03-22 18:30:17.645715",
7
"modified_by": "[email protected]",
8
"parent": null,
9
"parentfield": null,
10
"parenttype": null,
11
"idx": 0,
12
"docstatus": 0,
13
"report": "TEST",
14
"filters": [
15
{
16
"name": "2da4c94949",
17
"owner": "[email protected]",
18
"creation": "2020-02-29 14:40:58.218626",
19
"modified": "2020-03-22 18:30:17.645715",
20
"modified_by": "[email protected]",
21
"parent": "TEST",
22
"parentfield": "filters",
23
"parenttype": "Renovation Report",
24
"idx": 1,
25
"docstatus": 0,
26
"label": "Email",
27
"fieldname": "email",
28
"reqd": 0,
29
"fieldtype": "Link",
30
"options": null,
31
"default_value": null,
32
"doctype": "Renovation Report Filter"
33
}
34
]
35
}
Copied!

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
Last modified 1yr ago