How to validate the field attach in doctype, If I want to use custom script?

Hi, People

I need to explain how to do this thing.

In Doctype Oportunidad, has five field type attach, but I need to make sure something is attached.

I do this Script

frappe.ui.form.on(“Oportunidad”,“refresh”, function(frm)
{
if (frm.doc.mv!=’ ')
{
msgprint(“Field is empty”);
}
});

Look mv is a fieldtype like attach in my doctype but I don’t know how to do this validation. (frm.doc.mv !=’ ')

Can I help me or show some documentation about that.

thank u

if (!frm.doc.mv)

2 Likes

Thak you, Work It

But to attach first I have to save the doctype, there is a function that validates that the document was saved

The script complete is
frappe.ui.form.on(“Oportunidad”,“validate”, function(frm)
{

if ((frm.doc.mv==null || !frm.doc.mv || frm.doc.mv==“”) && frm.doc.estado==“Borrador”) {
msgprint(“Favor de adjuntar información necesaria”);
validated=false;
return false;
}
});

Any function that has the save value the doctype ?

I found the solution about this validation, I using the var workflow.

Thank u