Script not working when using a webform

Hi! I have 2 doctypes, A and B. I’ve created a Custom Script so that every time a document is created in Doctype A, some information is inserted in Doctype B.

e.g.: Doctype A has the field name so the name is transferred to the field name in Doctype B.

frappe.ui.form.on("GC1", {
	after_save: function(frm) {{
					method: "frappe.client.insert",
					args: {
						doc: {
							"doctype": "GC2",
							"nombra": frm.doc.nombre

To this point everything works fine. The problem appears when I create a web form based on Doctype A (called ‘GC1’). I complete the field for name, the document is created and I can see it on the list of GC1 documents but the creation on Doctype B (called ‘GC2’) isn’t happening anymore. I’m not quite sure about the direction of the workflow from this point. I’ll appreciate any help, thanks!

I’m not really sure as I’m not a developer. But from my experience using webform, this is my take:

The Webform has its own frontend (js) different from a Form frontend.
So if your js code is on the Form side to connect to the py, the Webform will not pick it up. You need to make the same js script on the Webform side.

It is something like:

frappe.web_form.after_load = () => {{
        method: "frappe.client.insert",
       # complete the code here

The file is in app/app/webform/webform_name.js

Or, do it directly in the Form’s py file. The webform will connect to it.