Renovation
Search…
.meta
A controller containing properties and methods about the models (meta data).

Things to know

It is recommended for better support of types by code assistance in IDEs to usegetFrappeMetaController()in order to get the instance of FrappeMetaController instead of renovation.meta which is MetaController if the backend is Frappè, for instance. In this guide we will use Frappé as an example and use getFrappeMetaController().

.getDocCount()

To get the number of documents based on a filter.

Input

property
type
required
description
doctype
String
yes
The target doctype
filters
dynamic
no
Filters based on DBFilter class

Output

RequestResponse<int>

Example

1
RequestResponse<int> docCount = await getFrappeMetaController().getDocCount(
2
doctype: "Chat Profile",
3
filters: [
4
["name", "LIKE", "[email protected]"]
5
],
6
);
7
8
if (docCount.isSuccess) {
9
print("Number of docs : ${docCount.data}");
10
} else {
11
print(docCount.error);
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

Invalid Frappe Filter

type: InvalidFrappeFilter
cause: The supplied filter doesn't comply with DBFilter
suggestion: Make sure the filter comply with DBFilter class

.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

property
type
required
description
doctype
String
yes
The target doctype

Output

RequestResponse<DocType>

Example

1
RequestResponse<DocType> docMeta =
2
await getFrappeMetaController().getDocMeta(doctype: "User");
3
4
if (docMeta.isSuccess) {
5
print("Doc meta : ${docMeta.data}");
6
} else {
7
print(docMeta.error);
8
}
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

property
type
required
description
doctype
String
yes
The target doctype
docname
String
yes
The target document

Output

RequestResponse<FrappeDocInfo>

Example

1
RequestResponse<FrappeDocInfo> docInfo = await getFrappeMetaController()
2
.getDocInfo(doctype: "User", docname: "[email protected]");
3
4
if (docInfo.isSuccess) {
5
print("Doc info : ${docInfo.data}");
6
} else {
7
print(docInfo.error);
8
}
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

property
type
required
description
doctype
String
yes
The target doctype
fieldname
String
yes
The target within the doctype

Output

String

Example

1
String fieldLabel = await getFrappeMetaController()
2
.getFieldLabel(doctype: "Renovation Review", fieldName: "reviewed_by");
3
4
print("Field label: $fieldLabel");
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

property
type
required
description
report
String
yes
The name of the Renovation Report report

Output

RequestResponse<RenovationReport>

Example

1
RequestResponse<RenovationReport> reportMeta =
2
await getFrappeMetaController().getReportMeta(report: "TEST");
3
4
if (reportMeta.isSuccess) {
5
print("Repot meta: ${reportMeta.data}");
6
} else {
7
print(reportMeta.error);
8
}
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