Bulk Update for multiple fields

Need to perform bulk update for multiple fields at same time.

frappe.call({ method: 'frappe.desk.doctype.bulk_update.bulk_update.update', 
				      args: { doctype: 'doctype', 
						field: [cur_frm.doc.field1,cur_frm.doc.field2], 
						value: [value1,value2], 
						condition: "name='"+field_id+"'"

For single field,its working but not working with multiple field-values.
Any help will be deeply appreciated.

Thanks In Advance

what is field_id??

it is the id of field where i want to update the fields

which is custom variable??

value 1 and value 2

Looking at frappe.desk.doctype.bulk_update.bulk_update.py doesn’t seem like it can handle multiple fields at once.
data[field] = value

So any alternate approach to do the same ??

Updating multiple field values for multiple doc forms ??

If you are able to modify py, you could create a custom whitelisted action in your custom app. I don’t think this is generic enough requirement to be pushed in as PR

Any way else to update multiple fields at same time via custom script ?

RBAR… You can update one field at a time in for loop,if it’s just 2 fields, can try run_serially()

can you give some references for using run_serially()

You could try something like

		let tasks = [];
		var update = function (field_id, field, value) {
			return frappe.call({
				method: 'frappe.desk.doctype.bulk_update.bulk_update.update',
				args: {
					doctype: 'doctype',
					field: field,
					value: value,
					condition: `name='${field_id}'`

		tasks.push(() => {
			return update("1", "1", "1");

		tasks.push(() => {
			return update("2", "2", "2");

		return frappe.run_serially(tasks);

u mean to say let field has 3 fields in comma seperated and values also has 3 values comma seperated so

return update("1", "1", "1");

will choose first value and field automatically and so does for the next one ?

I mean like

return update("field_id", "field1", "value1");


return update("field_id", "field2", "value2");

and what if I want to update 5 fields of id-A, 5 fields of id-B and 5 fields of id-C at same time where fields for all are same (ie field 1,2,3… are same for all three A,B and C)

check this i think this help you.

1 Like

Some changes and it worked.