.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

RequestResponse<int> docCount = await getFrappeMetaController().getDocCount(
doctype: "Chat Profile",
filters: [
["name", "LIKE", "abc@user.com"]
],
);
if (docCount.isSuccess) {
print("Number of docs : ${docCount.data}");
} else {
print(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

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

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

.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

RequestResponse<FrappeDocInfo> docInfo = await getFrappeMetaController()
.getDocInfo(doctype: "User", docname: "abc@user.com");
if (docInfo.isSuccess) {
print("Doc info : ${docInfo.data}");
} else {
print(docInfo.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

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

String fieldLabel = await getFrappeMetaController()
.getFieldLabel(doctype: "Renovation Review", fieldName: "reviewed_by");
print("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

property

type

required

description

report

String

yes

The name of the Renovation Report report

Output

RequestResponse<RenovationReport>

Example

RequestResponse<RenovationReport> reportMeta =
await getFrappeMetaController().getReportMeta(report: "TEST");
if (reportMeta.isSuccess) {
print("Repot meta: ${reportMeta.data}");
} else {
print(reportMeta.error);
}

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