nikzz
August 28, 2018, 10:09am
#1
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
nikzz
August 28, 2018, 11:08am
#3
it is the id of field where i want to update the fields
which is custom variable??
vijaywm
August 28, 2018, 12:06pm
#6
Looking at frappe.desk.doctype.bulk_update.bulk_update.py doesn’t seem like it can handle multiple fields at once.
`…
data[field] = value
…
nikzz
August 28, 2018, 12:08pm
#7
So any alternate approach to do the same ??
Updating multiple field values for multiple doc forms ??
vijaywm
August 28, 2018, 12:17pm
#8
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
nikzz
August 28, 2018, 2:00pm
#9
Any way else to update multiple fields at same time via custom script ?
vijaywm
August 28, 2018, 2:36pm
#10
RBAR… You can update one field at a time in for loop,if it’s just 2 fields, can try run_serially()
nikzz
August 29, 2018, 2:56am
#11
can you give some references for using run_serially()
vijaywm
August 29, 2018, 3:31am
#13
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);
nikzz
August 29, 2018, 3:37am
#14
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 ?
vijaywm
August 29, 2018, 4:12am
#15
I mean like
return update("field_id", "field1", "value1");
and
return update("field_id", "field2", "value2");
nikzz
August 29, 2018, 10:39am
#16
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
nikzz
August 30, 2018, 6:10am
#18
Some changes and it worked.
Thanks…!!