Customize Form and Fetch Data


I want to image and item name in job card. I added image and item name field in doctype job card. And I added custom script like below picture.

But it’s not work. Result is like below picture.

What can I do for fetch data?

Any idea??

you’ve only added the statements that’ll fetch but you need to write the function that encloses these statements too. it’ll be like this.

frappe.ui.form.on('Job Card',{
    'refresh' : function(frm){

instead of refresh you can use whatever event you want.

Thank you so much, I add these code in custom script as doctype job card, don’t I?

Yes you can directly replace your script by this one. If it does not work, post the error here and we can work it out. Also specify what field is being fetched from where and on what event or what should trigger this fetch.

There should be a small custom script tutorial with examples just down the Custom Script doctype

It doesn’t work. I want to fetch by bom no but fetching by bom no doesn’t work. I don’t know fetch by which field. Also I try your code for fix problem which is below video. Also it’s doesn’t work?

Problem Video

1 Like

Okay I got it. This JS should be applied not on Job Card but this child doctype you are using. I thought these fields were in the Job Card doctype itself, but these are in the Child Doctype.

You can directly fetch this from Item if you can make use of Fetch From ! No script required.

What is this child doctype name ? Is it a custom doctype you made ?

I try fetch item with Fetch From ! but it didn’t work. Doctype is Job card not child doctype or custom doctype.

can you share screenshot of what you customized ? I hope you are using Customize Form and not Edit DocType

Yes I used customize form I didn’t edit doctype. Screenshot is bellow.

(I ticked up what I customize field)