How to set Print Format based on user using custom script

How to set Print Format based on user using custom script

Thank you for your post, actually, I need this more in my case, please if you achieve any solution, share it with me
Thank you in advance.

I used this in V12, but after updating to V13, it’s stopped working. Hope this helps.

frappe.ui.form.on(“Sales Invoice”, {
refresh: function (frm, cdt, cdn) {
$(document).off(‘click’,‘i.fa-print’).on(‘click’,‘i.fa-print’,function(){
if(frm.doc.customer_group.includes(“Retail”) || frm.doc.customer_group.includes(“Project”)){
$(‘select.print-preview-select’).val(‘POS’).change();
} else {
$(‘select.print-preview-select’).val(‘Invoice’).change();
}
frm.refresh();
});