How can I assign a default value to a link field using JavaScript?

Hello community members,

I attempted to set a default value for a link field (“category” field in this case) in the onload() function, but it doesn’t seem to be working. Any support would be greatly appreciated.

Thank you

@thinkdigital you have set wrong value 1 you can’t set it set like kitchen or dining or change event validate or refresh

In the category table 1 and 2 are valid values.

Am i missing something?

@thinkdigital select value in category and check what value is set in this field using cur_frm.doc.category
I think category document is created using category name fieldname right

Hi @jeel, Thank you for your response.
I tried it and 1, 2 are valid values.


1 Like

Thank you for your assistance. It was a simple mistake. The value should be an integer; I previously passed it as a string. It should be:

frm.set_value('category', 1);

instead of:

frm.set_value('category', '1');

1 Like