To fetch example a field from item doc once item code is selected you must use fetch from for the new field and keep data type as data and use code Item_code.custom_code


Below is screenshot to guide you to make the same related to other doc types.