While making a naming series, i only want year to display

Hi i am making naming series for the journal entries. So i am using the format naming series.
format:LT/JV/{posting_date}/{#####} and it is printing LT/JV/2024-01-16/00004. But how can i show it as LT/JV/2024/00004.
Basically i want to do indexing in posting date.
Your help will appreciated.
Thanks.

Hello @Aditya_vig1 Use this format → LT/JV/.YYYY./

Hope this helps.

Regards,
Manju

Hy @Aditya_vig1

Use naming_series. I hope it’s working

LT-JV-.YYYY.-.MM.-.DD.-

Thank You!

Hi @Manjunath_Sajjan
Actually the reason i am taking posting date is because i want to display the year of posting date in saved journal entries which can be 2022, 2023 or 2024.
By this it will display the year 2024.
for eg : LT/JV/2024/00007, LT/JV/2023/00007, LT/JV/2022/00007
I hope it explains what i want.
Thanks.

hi @Mohammadali
thanks. But i just posted my requirement. Please see it for understanding it

Hy @Aditya_vig1
Try It

LT-JV-.posting_date.-.####

Thank You!

Hi @Mohammadali
i don’t want to display date and month. I only want to display the year
LT/JV/2024/00007, LT/JV/2023/00007, LT/JV/2022/00007. Like this.

thanks

Hy @Aditya_vig1

Use this script

frappe.ui.form.on('Doctype Name, {
	validate:function(frm) {
	    let d = new Date(frm.doc.posting_date);
	    let year = d.getFullYear();
	    let ym = "LT-JV-" + year + "-.#####";
	    frm.set_value("naming_series", ym);
	}
});

Thank You!

1 Like

@Mohammadali thank you so much.
I used your code. But i think there are few things which i must do in doctype settings of journal entries.


What should be in the autoname field?

it will auto name by field for example

you create a field Label Date , set it as Data type , when you save your doctype there will be a field name stabled in your doctype so you can use as reference field:here your actual field name

Hy @Aditya_vig1

View this image. I hope you will understand

Thank You!

3 Likes

Thanks @Mohammadali . Its done!!

1 Like