getTaggedDocs method
Gets all the names of all documents with the param-tag.
If the tag doesn't exist, an empty array is returned.
Returns failure if the doctype.
Implementation
@override
Future<RequestResponse<List<String>?>> getTaggedDocs(
{required String doctype, String? tag}) async {
EmptyDoctypeError.verify(doctype);
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: <String, dynamic>{
'cmd': config.coreInstance.frappe.frappeVersion!.major == 12
? 'frappe.desk.doctype.tag.tag.get_tagged_docs'
: 'frappe.desk.tags.get_tagged_docs',
'doctype': doctype,
'tag': tag ?? ''
});
if (response.isSuccess) {
List result = response.data!.message;
if (result.isNotEmpty) {
return RequestResponse.success(List<String>.from(result[0]),
rawResponse: response.rawResponse);
}
return RequestResponse.success([], rawResponse: response.rawResponse);
} else {
return RequestResponse.fail(
handleError('get_tagged_docs', response.error));
}
}