Save button doesn't appear using Onload Trigger even when form is dirty [V15]

Hi,

After setting values on a form via client script (frm.set_value), the Save button doesn’t appear. Instead, the Actions button (from Workflow) remains visible though the status of the document shows as ‘Not Saved’

Setting the form as dirty directly via script (frm.dirty()) still doesn’t solve the issue. Is this a bug ? Would appreciate any suggestion on how to get around this without using frm.save()

Thanks

@wale can you share SS of workflow

Hi @wale:

I’m curious about it … Save button is always shown. Tried with a “brand new” document, before and after modification with frm.set_value
Any specific doctype?

Hi @Jeel

Its just a basic workflow… Pls see below:

Hi @avc

Stock Entry

I haven’t encountered this with any other doc so far

@Jeel @avc

Pls see custom script for reference:

frappe.ui.form.on("Stock Entry",{
	onload: function(frm) {
		if (frm.doc.stock_entry_type == "Material Receipt" && frm.doc.docstatus == 0) {
			frm.set_value("set_posting_time", 1);
			frm.refresh_field('set_posting_time');
			frm.dirty();
			console.log(frm.is_dirty());
		}
	}
});

Thanks

I just noticed something…

Changing the trigger to ‘Refresh’ seems to solve the issue… Not sure why the ‘Onload’ trigger is doing this with Stock Entry especially as it works fine on other docs

Hi @wale:

AFAIK onload is triggered before render the form … refresh is triggered after form is loaded and rendered.

Glad to know it’s working now :slight_smile:

Good point… So there’s likely something in the standard logic that runs during or post render which causes this to hapen

:sweat_smile:

Thanks @Jeel @avc …your responses and pointers are much appreciated

Kind regards,

1 Like