Lead want to save based on company

Hello guys

I want to save leads in different naming series.

I connected the lead with API so the lead will get from different companies’ websites automatically saving the contact us, so I want to save the lead based on the company.
I added some custom scripts.

if(frm.doc.company==" Company 1")
else if (frm.doc.company==" Company 2")

But it is not working. Please help me with this also I want to change the company field position to above from more information so for that I edit the JSON file (lead.json) and migrate no error found but the poison of company did not change

Please help me to find any solutions

Hi @jinsy,

Please check it.

frappe.ui.form.on('Lead', {
     company(frm) {
         if (frm.doc.company == "Company 1") {
             frm.doc.naming_series = "CF-DXB-.YYYY.-";
         else {
             frm.doc.naming_series = "CF-EKM-.YYYY.-";

Thank You!

Thanks for the quick response :slightly_smiling_face: but it is not working

Please try to change trigger then check.


First check to when manually create lead then it’s work or not?


Sorry for that.

In my side only work before_save trigger so you can use before_save then check it.



I did it manually it is working but when leads come from the website it saves in one naming series

use server script for same

I’m new to this field, can you please explain how to apply the server script