Need help to make custom script

I am running
ERPNext: v6.27.15 :
Frappe Framework: v6.27.16

I developed a new app product master and a doctype inside the app with the same name product master .
i) I have three fields edger,blocker and finisher , i want to add all the three fields and display that in field named total.
ii) Then i do have a custom field named c_max this should not be lesser than a field named c_min .

My module and doctype share the same name product master.

Tried few custom scripts available in the internet , nothing worked . It would be of great help if someone could provide me a tutorial link on custom script syntax .

Thanks in advance,

Ragav

@ragav, I doubt that creating multiple topics with the same issue will help you get some response from community.

@ragav Share the custom script that you tried, maybe we can help you to fix it, but I think that the purpose of this forum is not find people to do the work to you!

Sorry for that , but i am afraid if my post is not noticed ?

I understand sir , but i am a novice it will be of great help if you correct the below script :

frappe.ui.form.on(“Product master”, “total”, function(frm, doctype, name) {
var row = locals[Product master][product_master];
row.total = row.edger + row.blocker + row.finisher;
refresh_field(“total”);
});

You could’ve posted to the original topic if you are afraid that nobody noticed it, but even bumping is not usually considered as a part of perfect etiquette. Don’t forget that this is community forum, not paid support one.

@ragav

1 - Take care of the case, because Python and Javascript are case sensitive languages!
2 - You need bind your event, in the fields that the user can interact, and not in the total!

So, you need run this function in edger, blocker, and finisher

3 - use the aliases frm.doc instead of locals["Product master"]["product_master"] and frm.set_value("total", 10);

tried running the above script but the problem persists sir .

@ragav I dont sent a script to you! I send a group of changes to you understand and follow!

Apply these changes in your script, and if dont works, dont forget of post here your updated script!

Big Tip: https://frappe.github.io/frappe/user/en/tutorial/form-client-scripting.html

Thanks for the tips sir , i tried running this script ,

frappe.ui.form.on(“Product master”, “total”, function(frm, doctype, name) {
var row = frm.doc[Product master][Product_master];
frm.set_value row.total = row.edger + row.blocker + row.finisher;
refresh_field(“total”);
});

Hi All,

Please someone help me ,I am able to set a value to a field using below script but instead of this value 12 i want to add values of three other custom fields in the same doctype , field names are edger, blocker and finisher . I want to add all these three fields and display it in a field named total .

frappe.ui.form.on(“Product master”, “total”,function(frm) {
frappe.model.set_value(frm.doctype,frm.docname,“total”,12)
refresh_field(“total”);
});

Thank you sir , now I understood what you meant . It works !!! Thanks a lot sir

This topic was automatically closed after 2 days. New replies are no longer allowed.