Ok so first of all, @rmeyer thanks for your help.
I sat a little while now to understand your code snippet, because one line made me work properly to understand it, because at some point it turned out that there was the problem.
To understand your code snippet I added some jscript alarm functions, which show me the value of the respective constant/variable.
I wanted to add at this point, that my javascript knowledge is pretty much the same as a beginner.
Nevertheless I approximately know how to start.
Let’s go through the lines.
If I have understood this correctly
locals[cdt][cdn]
already a provided function of the, Frappe Framework.
const target_row = locals[cdt][cdn];
window.alert('target_row: ' + target_row);
Here it is only confirmed that I will get a constant of the datatype object.
I also know (because of the alarm) that JScript has already recognized that the field get_component has been activated.
const item_name = target_row.get_component;
window.alert('item_name: ' + item_name);
Here I get the respective number of the component, which I have selected in the field get_component at this moment.
if (item_name)
If I interpret the if line correctly, then it says here If the constant item_name exists or a value is stored for it, then…
const item_doc = frappe.model.get_doc('item', item_name);
window.alert('item_doc: ' + item_doc);
Here the same as in the first lines.Only the information that I will get a constant of the data type object.
item_doc: [object Object]
The next line brought me difficulties, because I was constantly told that source_row is undefined, which I didn’t understand.
const source_row = item_doc.supplier_items[0];
window.alert('source_row: ' + source_row)
In addition to that the compiler did not compile anything else (at least the last lines of the overall function). I think so, because I placed an alarm function afterwards and it didn’t appear anymore.
By coincidence I found out that I really had no value in the field supplier. This was because last night, due to server problems, I did a rollback of the virtual server. Afterwards, as I thought of course, I brought the DocTypes back to the correct status and as it looks like I forgot to enter the supplier in the item again.
Now that everything is working, it is of course much easier to understand the code!
I would say let’s finish the line description for the other users anyway.
target_row.supplier_name_offer_bom = source_row.supplier;
window.alert('target_row.supplier_name_offer_bom: ' + target_row.supplier_name_offer_bom)
This is where the content of the supplier field from the Item Supplier table is stored.
and then the command
frm.refresh_field('components_offer_bom');
refreshes the whole table.
I hope I have interpreted the lines correctly and would be happy (if I am wrong) to be corrected here.
You and the other users from this thread were a great help to me to get closer to the principle of ERPNext! From there I say thanks again!