searchLink method
Returns a list of SearchLinkResponse after searching against fields.
By default, the search is done against the name
field.
options
can be used to control the search. For instance searching against mobile_no
:
{
"searchField": "mobile_no"
}
Returns a successful RequestResponse with empty list if the query has no results.
If the doctype doesn't exist, a failure is returned.
Implementation
@override
Future<RequestResponse<List<SearchLinkResponse>?>> searchLink(
{required String doctype,
required String txt,
Map<String, dynamic>? options}) async {
EmptyDoctypeError.verify(doctype);
options ??= <String, dynamic>{};
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.GET,
contentType: ContentTypeLiterals.QUERY_STRING,
queryParams: <String, dynamic>{
'cmd': 'frappe.desk.search.search_link',
'txt': txt,
'doctype': doctype,
...options
},
isFrappeResponse: false);
if (response.isSuccess &&
response.data != null &&
response.data!.message is Map &&
response.data!.message['results'] is List) {
List? temp = response.data!.message['results'];
final results =
SearchLinkResponse().deserializeList<SearchLinkResponse>(temp);
return RequestResponse.success(results,
rawResponse: response.rawResponse);
} else {
return RequestResponse.fail(handleError('search_link', response.error));
}
}