Problem with set_value

I’m trying set value by javascript, but when i reload the page the values gone.
After reload, clear the fields

callback: function(r) {
  let doc_name = r.message.name;
  d.serie_parcela = doc_name;
}

In that way this it not finding the field serie_parcela:

callback: function(r) {
  let doc_name = r.message.name;
  cur_frm.set_value(d.serie_parcela, doc_name);
}

I tried .save(), but this change the docstatus of document

You are not calling set_value correctly. If this is a parent document, it should be:
cur_frm.set_value("serie_parcela", doc_name);

If it is a child doc use:
frappe.model.set_value(cdt, cdn, "serie_parcela", doc_name);

1 Like

It’s a child table field
Trying, thanks!

Tried:

Error: Resource is not avaible

Not sure why that would be happening, unless you haven’t declared cdt and cdn. Can you share all your code?

The code:

https://github.com/leonardoaugt/financeiro/blob/master/financeiro/public/js/purchase_invoice_doctype.js#L17

Since you have it in a $.each loop, you need to get the doctype and docname through that.

frappe.model.set_value(d.doctype, d.name, "serie_parcela", doc_name);

worked, but the same problem when i reload page… clear the fields

Why don’t you just do it in the python file. You need to run save() to save it on javascript

So in callback, i have to call another method in python to do this… right?

.save() in server side is not working too, omg…

Not allowed to change series after submission, and now? has some ignore function?

Worked now!

It worked for me, thank you very much :slight_smile:

How did that worked?

when i’m using doc.save() it creates new record instead of updating.

Kindly help