Sum of Items (z = x+y)

Hi there, I’m new on erpnext and frappe application. And I have created a custom doctype, in which I have 3 Fields, x, y, z. They are the three float variables, but I’m needing the sum of (x+y) = z. I meant z hace to be equals to x+y, helllllpp me pliss. It’s just to start understanding the custom’s scripts :frowning:

1 Like

So sorry for destroying your dreams, the above issue were requested with no help at all.

Essential needs! - Math Calculations Wizard for Custom Fields and Forms

Please share what you can reach with custom scripts.

I did not undestand what you tried to say, but I am new on this, and there is not too much info about the environment, so if you can help me, please do it, i’m a PHP developer, but sometimes you need to change your environment

I just saying I’m seeking the same.
going deep, there’re two types of erpnext scripts, they call it, server-side and client-side
As i understood, client-side can be somehow, on-the-fly calculation of x+y during say print-out but will not be reflected to the database.
that requested feature is about standardizing the math calculation to be apart of the customization module and to be reflected to the database i.e. server-side

@anibalrljose

Welcome.
You first go through following links. you will get an idea of the custom script.

User Manual

Custom Script

Custom Script Examples

1 Like

But I just need that easy sum to know the way it works, because i don’t need to be a master to do what I’m going to do

Create a custom scrip select your custom doctype as DOCTYPE and add and modify this scrip as needed

frappe.ui.form.on(“CUSTOM DOCTYPE”, “refresh”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “z”, d.x+ d.y);
refresh_field(“z”);

1 Like

@Randy_Lowery

This is the code you gave me:

frappe.ui.form.on(“CUSTOM sum”, “refresh”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “z”, d.x+ d.y);
refresh_field(“z”);
});

aplied to my doctype name, but it isnt working yet. Its just left me the field z=0 as it started

can you share screenshots of your custom doctype? or the actual field names?

@Randy_Lowery This is the doctype i have create

your doctype name is sum so the scrip will look like this:

frappe.ui.form.on(“sum”, “refresh”, function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “z”, d.x + d.y);
refresh_field(“z”);
});

NOTE: first after saving the new scrip always do a refresh on your browser.
This scrip will only work after you hit save .

1 Like

Oh Great thanks, you’re a great one.

What if I need take that field and save it to another doctype? Thank you @Randy_Lowery

Here is a reference:

Coool thankyou I’ll be working on that, really thaks dude