Make field visible after document creation

Hello community.

I’d like to make a field visible after the document has been created. How can we make it happen?

The reason behind it is, because it’s an “attach” field, and attachments do not get put to the left sidebar currently. They only get put to the sidebar after creating the document and attaching the document. I don’t know if it’s by design, or a bug and I’d like to avoid user errors :slight_smile:

Try this code:

frappe.ui.form.on('DocType', {
refresh: function(frm) {
	if (frm.doc.__islocal) {
		hide_field(['attach_field']);			
	}
}

});

2 Likes

Thank you so much! It’s working beautifully. However, user user must refresh the document after creating. Anyway to avoid it? :smiley:

@iMoshi use onload_post_render insted of refresh

1 Like

Hasn’t worked, same result. I’m on latest develop by the way (v13) :slight_smile:

what is the use case?

I have a custom doctype (submittable) and have “attach” field inside it. When a user is creating a document, he attaches a relative document using the attach field, and upon saving it does not get listed to the sidebar, making it impossible to review the attachment after submitting the document.

The attachment only gets put to the sidebar after creating the document without attaching anything when creating, and then attach the file after the document is created.

So, to avoid user error I’d like the field populated after creating the document :slight_smile:

I’d actually like this behavior to be fixed inside Frappe though :slight_smile:

Try “Depends on” with
eval:!(doc.__islocal)

3 Likes

Brilliant! Worked like a charm.

Thank you so much!