Default value for Integer field and setting in JavaScript

Hi guys,

I am having an issue with setting default value (0) for Int field - it is not visible although when:

cur_frm.doc.my_int_field

it returns 0.
When I use

cur_frm.set_value(“my_int_field”, 0);

it is still invisible in the form.
Above is connected with add_fetch which only works when there is some value like 1 or 2 or whatever.
To mitigate it user has to pick link value two times.
How can I fix it?

1 Like

Update #1

it does not matter if the default value is 1 or 2.
On cleared cache you have to call add_fetch twice. And of course you cannot do it one call by another - two separate value changes (tried on production & dev)

Update #2

I was able to get it working calling add_fetch on refresh event, however I find it very unelegant.

Update #3

Unfortunately when using fast entry on object of interest it does not work as well (has to pick it after it is inserted to DB).

Update #4

After switching to classic

frappe.call({
method: “frappe.client.get_value”
(…)
});

It works like a charm, looks like an add_fetch issue.
Any tips appreciated :slight_smile:

@netchampfaris any suggestions?

1 Like

@Pawan
@netchampfaris

No solution for above? :slight_smile: