Specific user to custom naming_series of an issue

Hi all, i have try to limit a specific user to custom naming_series of an issue.
i have created 3 type of issue NCR-## NCF-## NCS-##
i have 3 Branch I need Link each branch to its own series automatically without the selection of the employee

You can set the naming series automaticly with an custom script

can you seed to me custom script

therefore i need more information:
on wich conditions should the script take wich naming series?
how is the fieldname of the naming series called?

fieldname is branch
like if branch == (almaza) aming_series == (Al-maza-)

Try something like this:

frappe.ui.form.on('Issue', {
	before_save(frm) {
		if (frm.doc.branch == 'almaza') {
			cur_frm.set_value('naming_series', 'Al-maza-');
		}
	}
})

not working
image
image

frappe.ui.form.on(‘Issue’, {
before_save(frm) {
if (frm.doc.branch == ‘Elkawsar’) {
cur_frm.set_value(‘naming_series’, ‘SI-ELkawsar-’);
}
}
})

Frappe Framework

Open Source Applications for the Web

Website: https://frappe.io

Source: Frappe · GitHub
Installed Apps

ERPNext: v12.1.5 (version-12)

Frappe Framework: v12.0.15 (version-12)

© Frappe Technologies Pvt. Ltd and contributors

I think now I understand it!
you do not use the doctype “Issue” and a field of issue is “branch”, rather your doctype is called “Branch”!

So, let’s put the script you want into words;
When a new record (of doctype “Branch”) is created, the script should set the naming_series automatically. If the field “XXX” is the value “YYY”, the naming_series should be “ZZZ”.

Ist that correct? If yes, could you please define for me “XXX”, “YYY” and “ZZZ”?

yes
If Branch== (Elkawsar) , Naming Series == (SI-ELkawsar-)
If Branch== (NOR) , Naming Series == (SI-NOR-)
If Branch== (Star) , Naming Series == (SI-Star-)
If Branch== (ASFour) , Naming Series == (SI-ASFour-)

So you have in the doctype “Branch” also a field called “branch”??

yes link field

ok, and in the doctype"branch" you have also a field called “naming_series”, based on this the record will be named, correct?

correct

Well, then this should work:

frappe.ui.form.on('Branch', {
	before_save(frm) {
		if (frm.doc.branch == 'Elkawsar') {
			cur_frm.set_value('naming_series', 'SI-ELkawsar-');
		} else if (frm.doc.branch == 'NOR') {
			cur_frm.set_value('naming_series', 'SI-NOR-');
		} else if (frm.doc.branch == 'Star') {
			cur_frm.set_value('naming_series', 'SI-Star-');
		} else if (frm.doc.branch == 'ASFour') {
			cur_frm.set_value('naming_series', 'SI-ASFour-');
		}
	}
})

thanks for help but still not working

The code as itself is correct, so the problem have somewhere else.
What does youre webbrowser console logs say?

the messaged is
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.githubusercontent.com/frappe/emoji/master/emoji. (Reason: CORS request did not succeed)