I’ve been trying to automate a document creation process by making a doctype which acts as a wizard. I have a script set to take all the inputted values and create the various documents necessary.
It runs perfectly fine, till the frappe.db.insert() (I have tried contact.insert(), but the do the same thing, literally), where the script then just stops, it doesn’t error, it doesn’t continue with broken values, it just stops. I can re-validate to infinity, but the script always stops there, I don’t know why…
I’ve tried pretty much every way possible to insert this new document including: frappe.run_serially (works, but its not transparent, which is what I would like, and doesnt run well on validations), frappe.call (Not Allowed), frappe.get_doc (no different from new_doc with args), so I’m kida stuck.
I have tried saving a newly created document via JS route but nothing helped. If you can write similar code in Python and call this function in this Custom script then you will be able to do most of the basic ops on files such as create, update, save, submit, cancel.
Very little info on hosted js only document scripts. This script works. Shows parent fields and child fields. It has all the mandatory fields for PO items:
JavaScript usually doesn’t work this way; your log statement will be executed before the callback method, without any data in the variable. However, you can wait for the promise to return by using async and await.
Not exactly,In the above solution you have inserted childtable like
items: [
{
‘item_code’: ‘XXX141- C - WF’,
.
.
.
}
which means only the 1st row is filled,What i wanted is that to insert one more row with may be item_code as ‘XXX142 - C- WF’ while the time of Creating a new document(using frappe.db.insert({}) )