assignDoc method
Future<RequestResponse<bool?> >
assignDoc({
- String? assignTo,
- String? doctype,
- bool? myself = false,
- DateTime? dueDate,
- String? description,
- String? docName,
- List<
String> ? docNames, - bool notify = false,
- Priority? priority,
- bool bulkAssign = false,
override
Assigns a doc or a list of docs to a particular user.
If the user is signed in, myself
can be set to true
where the assigned to will be the user signed in.
If multiple docs need to be assigned to a user, bulkAssign
can be set to true
and docNames
can be used instead of docName
.
Returns failure in case the doctype
does not exist in the backend.
Implementation
@override
Future<RequestResponse<bool?>> assignDoc(
{String? assignTo,
String? doctype,
bool? myself = false,
DateTime? dueDate,
String? description,
String? docName,
List<String>? docNames,
bool notify = false,
Priority? priority,
bool bulkAssign = false}) async {
// FIXME: possible to assign same doc twice, should be validated
final args = AssignDocParams(
assignTo: assignTo,
description: description,
myself: myself,
dueDate: dueDate,
doctype: doctype,
docName: docName,
docNames: docNames,
priority: priority,
bulkAssign: bulkAssign,
notify: notify);
args.cmd = args.bulkAssign!
? 'frappe.desk.form.assign_to.add_multiple'
: 'frappe.desk.form.assign_to.add';
if (args.myself!) args.assignTo = config.coreInstance.auth.currentUser;
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: (args
..name =
args.bulkAssign! ? jsonEncode(args.docNames) : args.docName)
.toJson());
if (response.isSuccess) {
return RequestResponse.success(response.isSuccess);
} else {
return RequestResponse.fail(handleError('assign_doc', response.error));
}
}