Hi
I have a suspicion that this might be a tall order … are there any FRAPPE calls / methods that can assist in implementing EXCELL-like equations in ERPNEXT. i.e. if I have a doc that has Field1 , FIeld2, Field3 … Field3 = Field1 *2+ FIeld1 . The user will then enter the equation in a “small text” field.
You can implement it via server side script. You may refer:- Server Side Scripting.
Something like:-
doc.summedfield = doc.field1 + 3* doc.field2 …
Thank you @shubham_agrawal for your response
I have also been reading up on the “Code” field in a doctype. Does this tie in to your
suggestion, in other words, I create a “Code” field where the user can enter an equation in the “formula_code” field and then I can execute it using either server-side script…
def evaluate_formula(doc):
formula = doc.formula_code
try:
result = eval(formula, {"doc": doc})
doc.calculated_date = result
except Exception as e:
frappe.msgprint(f"Error in formula: {e}")
or perhaps JS ( client script ) …
frappe.ui.form.on('Patient', {
refresh: function(frm) {
if (frm.doc.formula_code) {
try {
let result = eval(frm.doc.formula_code);
frm.set_value('calculated_date', result);
} catch (e) {
frappe.msgprint("Error in formula: " + e.message);
}
}
}
});
Am I interpreting your message correctly ?
Is there anyone that can help with this … am I on the right track ?
Hi @trainingacademy ,
You may use code in field type
while creating custom field. A similar logic is used in frappe hr for payroll (salary structure), you can refer it, that would be pretty relevant how you can achieve desired excel like logic creator.
Shubham