Calling Terms and Conditions

Greetings to everyone

You’ve created the Terms and Conditions, but when you choose them do not meet the requirements.
Look at the picture, table is empty

any solution?

You have to write an add_fetch to manage this.

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/custom-script-fetch-values-from-master

Can you help me?
how to add fetch?
what I write?

Create a doctype
Certificate template
inside make

  1. Cerficate Name (Name of the Certificate)
  2. Content (Content of the Certificate)

Then is the main form make custom fields

  1. Certificate template (Link) to certificate template.
  2. Certificate Content (Data ) certificate_template.content

This is a GUI Way to make Custom fetch

I guess you have created a new Doctype. Let’s say you have created DocType “Certificate Template” and its DocFields are

“Certificate Name” (defined as data)
“Content” (defined as text editor)

And now I guess you want to include the new DocType you’ve created in another Existing DocType, let’s say for example in Sales Invoice. In that case you must create new Docfields in Sales Invoice Web Form, calling them

1.- Certificate Name (defined as Link and pointing to your currently created “Certificate Template” DocType)
2.- Certificate (defined as Text Editor)

and placing them whereas you want after existing docfields in Sales Invoice Web Form.

Now, I guess that what you want is that in Sales Invoice, whenever you choose the Certificate Template in the dropdown, the data from the Certificate Template is shown in the Certificate Text Editor area. Is it correct?

If that’s the case, you must create a new custom script with the following code:

frappe.ui.form.on("Sales Invoice", "certificate_name", function(frm) {
   frappe.model.get_value( "Certificate Template", { "Certificate Name":  frm.doc.certificate_name}, "content", function(d){
     var text = d.content;
     frm.set_value( "certificate",  Text);   
   });   
});

All of that is guessing that you want to automatically fill the Certificate Area when you select a value in the Certificate Name. The only thing that you should take care is that if you place jinja variables in the Certificate Content, these variables will be shown as text and not taking the values from database as in Terms in Conditions DocType.

1 Like

This worked for me ,Thank you!