Can we restrict view of item by company wise
there are 2 items apple and orange apple is only for company 1 and orange for company 2
yes add a field in the item company and apply client script
frappe.ui.form.on(‘Item’, {
company: function(frm) {
// Triggered when the ‘company’ field changes
setFieldQuery(frm, [‘filedname’]);
},
refresh: function(frm) {
// Triggered when the form is refreshed
setFieldQuery(frm, ['fieldname']);
// Additional logic for other fields if needed
}
});
function setFieldQuery(frm, fields) {
fields.forEach(function(field) {
if (frm.fields_dict[field]) {
frm.fields_dict[field].get_query = function(doc, cdt, cdn) {
let filters = { ‘company’: doc.company };
if (field === 'fieldname') {
filters = { 'company': doc.company };
}
return { filters };
};
}
});
}
add your filed name if company not working try custom_company becuase new fields are saved with custom
Dont Have any built in function
1 Like
you can apply filters on to that field but you must add company in the item doctype