Issue with Custom Script and Custom Doctype

I have created a Custom DocType in which I am having 2 buttons.
New Product and Existing Product
When I press New Product button it displays few fields:

New Product Name and New Product Description

There are some conditions written in depends _on on each of these fields:

New Product Name
depends_on:
eval:doc.old_new=='New' && doc.added_to_order=='No'

New Product Description
depends_on:
eval:doc.old_new=='New' && doc.added_to_order=='No'

And on the new_product button I have written a code:

frappe.ui.form.on("Shipping Lists","new_product", function(frm, cdt, cdn) {
var d =locals[cdt][cdn];
frappe.model.set_value(cdt,cdn,"old_new","New");
});

Also I am setting the value of added_to_order

frappe.ui.form.on("Shipping Lists","add_to_order", function(frm, cdt, cdn) {
var d =locals[cdt][cdn];
frappe.model.set_value(cdt,cdn,"added_to_order","Yes");

Issue is when I make old_new field hidden it doesn’t display the other fields like
New Product Name and New Product Description
But when I make it visible it works.

Any idea what could be the issue?

Where did you set the value of added_to_order ?

What are you trying to do here?

@netchampfaris

added_to_order is a data field where I am checking the status whether it has been added to the order or not.
Apart from that I am updating the value of added_to_order on a button press called add_to_order
When user press the button, add to order then the item get added to the order and the value of added_to_order get updated to Yes.

frappe.ui.form.on(“Shipping Lists”,“add_to_order”, function(frm, cdt, cdn) {
var d =locals[cdt][cdn];
frappe.model.set_value(cdt,cdn,“added_to_order”,“Yes”);

Regards
Ruchin Sharma

Actually, I just checked that there is some issue with depends_on and the issue is.
If the field you are referring in depends_on is hidden then it doesn’t show the field where you have put depends_on.

Regards
Ruchin Sharma