@monojoker Looks like you are editing a table in the screenshot. If yes, create a custom script for your doc type or even better write a js file for your doctype and key in the following.
Thankyou that’s a great help. Sorry for the really stupid question but do I need to modify that code or will it work simply copying and pasting into my Sales Order Item custom script? I tried doing that but it doesn’t work - still not filling the job_type field with “New” when I add item_code “Artwork”.
I really am completely new to javascript so if you can let me know what I need to customise at my end in that script it’d be great.
Whoa, you’re going to have to elaborate on that. When I simply replace line 1 with that code I get just the headings on the Sales Order and no fields at all!
What I found with Bhupesh’s code is it worked great and populated the Job_type field but it prevented the automatic fill of the other fields like pricing, item description, etc.
@rmehta I assume your variant might stop that from happening but I cannot get it to work at all.
frappe.ui.form.on("Sales Order", "item_code", function(frm) {
var job = frappe.get_doc(frm);
if (job.item_code == "Artwork") {
job.job_type="New";
refresh_field("job_type", job.name, job.parentfield);
}
}
I actually tried that variant first before editing it down further and it had the same effect. I get the “blank” sales order with no fields just the headings. I might try a different solution - perhaps just not enforcing mandatory fields but using Depends On to display the data entry fields we need per Item Group.