web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Script error: Web resource method does not exist:

(0) ShareShare
ReportReport
Posted on by 107

I update my JavaScript to new format and get this issue:

Web resource method does not exist: ProductoPropuesta.formOnLoad. However the closest object we found is ProductoPropuesta that contains these properties: Please verify this object is not corrupt and is not an object of the same name defined elsewhere, such as another script.

ReferenceError: Web resource method does not exist: ProductoPropuesta.formOnLoad. However the closest object we found is ProductoPropuesta that contains these properties: . Please verify this object is not corrupt and is not an object of the same name defined elsewhere, such as another script.
at y._handleMethodNotExistError (wemasstest.crm4.dynamics.com/.../app.js
at y.execute (wemasstest.crm4.dynamics.com/.../app.js
at wemasstest.crm4.dynamics.com/.../app.js
at i (wemasstest.crm4.dynamics.com/.../app.js
at ee._executeIndividualEvent (wemasstest.crm4.dynamics.com/.../app.js
at ee._executeEventHandler (wemasstest.crm4.dynamics.com/.../app.js
at Object.execute (wemasstest.crm4.dynamics.com/.../app.js
at N._executeSyncAction (wemasstest.crm4.dynamics.com/.../app.js
at N._executeSync (wemasstest.crm4.dynamics.com/.../app.js
at N.executeAction (wemasstest.crm4.dynamics.com/.../app.js

Detalles del error:
Nombre del evento: onload
Nombre de función: ProductoPropuesta.formOnLoad
Nombre del recurso web: sing_productoPropuesta
Nombre de la solución: Active
Nombre del editor: DefaultPublisherwemasstest

My code is:

// Un NameSpace se define para el código a ejecutar
// Como práctica recomendada, siempre debe definir un NameSpace único para sus bibliotecas
// Para nuestro caso el NameSpace es la entidad Producto de la propuesta

var ProductoPropuesta = ProductoPropuesta || {};
(function () {
    // Defina algunas variables globales
    var myUniqueId = "_myUniqueId"; // Define un ID para notificar
    var currentUserName = Xrm.Utility.getGlobalContext().userSettings.userName; // get current user name
    var message = currentUserName + ": Your JavaScript code in action!";

    //Get Objects
    if(formContext.ui.getFormType() == 1) //Form = Create --- Especifique true para mostrar el control; false para ocultarlo.
    {  
        message = currentUserName + ": esta generando una nueva propuesta."
    }
    else if(formContext.ui.getFormType() == 2)//Form = Update
    {
        message = currentUserName + ": Proceso de modificar."
    }

    this.formOnLoad = function (executionContext) {
        var formContext = executionContext.getFormContext();

        // Display the form level notification as an INFO
        formContext.ui.setFormNotification(message, "INFO", myUniqueId);

        // Wait for 3 seconds before clearing the notification
        ProductoPropuesta.setTimeout(function () { formContext.ui.clearFormNotification(myUniqueId); }, 3000);

        this.CambiarEtiqueta(executionContext);
        this.Importe(executionContext);
        this.CalculoDescuento(executionContext);
    }

    this.attributeOnChange = function (executionContext) {
        var formContext = executionContext.getFormContext();

        // Automatically set some column values if the account name contains "Contoso"
        var accountName = formContext.getAttribute("name").getValue();
        if (accountName.toLowerCase().search("contoso") != -1) {
            formContext.getAttribute("websiteurl").setValue("">https://www.contoso.com");
            formContext.getAttribute("telephone1").setValue("425-555-0100");
            formContext.getAttribute("description").setValue("Website URL, Phone and Description set using custom script.");
        }
    }

    this.formOnSave = function (executionContext) {
        // Display an alert dialog
        //Xrm.Navigation.openAlertDialog({ text: "Record saved." });
        agrupaSegmentacion(executionContext);
        this.Importe(executionContext);
    }

    this.CambiarEtiqueta = function (executionContext) {
        var formContext = executionContext.getFormContext();
        var ProductoNombre = formContext.getAttribute("productid");
        var entity = formContext.data.entity.getEntityName();
   
        if (ProductoNombre != null && ProductoNombre.getValue() != null) {
            var ProductoNombreValor = ProductoNombre.getValue()[0].name;
   
            if (ProductoNombreValor != null)
            {
                if(entity == "opportunityproduct")
                {
                    if (ProductoNombreValor.indexOf('CPM') != -1)
                        formContext.ui.controls.get("sing_cantidad").setLabel("Impresiones");
       
                    if (ProductoNombreValor.indexOf('CPC') != -1)
                        formContext.ui.controls.get("sing_cantidad").setLabel("Clicks");
   
                    if (ProductoNombreValor.indexOf('CPV') != -1)
                        formContext.ui.controls.get("sing_cantidad").setLabel("Views");
                }
                else if(entity == "salesorderdetail")
                {
                    if (ProductoNombreValor.indexOf('CPM') != -1)
                        formContext.ui.controls.get("quantity").setLabel("Impresiones");
   
                    if (ProductoNombreValor.indexOf('CPC') != -1)
                        formContext.ui.controls.get("quantity").setLabel("Clicks");
   
                    if (ProductoNombreValor.indexOf('CPV') != -1)
                        formContext.ui.controls.get("quantity").setLabel("Views");
                }
            }
        }
    }

    this.Importe = function (executionContext)
    {
        var formContext = executionContext.getFormContext();
        var ProductoNombre = formContext.getAttribute("productid");
        var CantidadCPM = formContext.getAttribute("sing_cantidad");
        var CantidadCPMValor = CantidadCPM.getValue();
        var Cantidad = formContext.getAttribute("quantity");
        var CantidadValor = Cantidad.getValue();
        var ValorVisible = 0;
   
   
        if (ProductoNombre != null && ProductoNombre.getValue() != null) {
            var ProductoNombreValor = ProductoNombre.getValue()[0].name;
   
            if (ProductoNombreValor != null) {
                if (ProductoNombreValor.indexOf('CPM') != -1) {
                    ValorVisible = CantidadCPMValor / 1000;
                    Cantidad.setValue(ValorVisible);
                }
                else {
                    ValorVisible = CantidadCPMValor
                    Cantidad.setValue(ValorVisible);
                }
            }
        }
    }

    this.CalculoDescuento = function(executionContext){
        var formContext = executionContext.getFormContext();
        var Descuento = formContext.getAttribute("sing_descuento");
        //var PrecioUnidadBruto = formContext.getAttribute("sing_precioporunidadbruto");
        //var PrecioUnidadBrutoValor = PrecioUnidadBruto.getValue();
        var PrecioUnidad = formContext.getAttribute("priceperunit");
        var PrecioUnidadValor = PrecioUnidad.getValue();
        var TipoVenta = formContext.getAttribute("sing_tipodeventa");
        var TipoVentaValor = TipoVenta.getValue();
        var Valor = null;
        //********************************************************************************* */
        var productoLookup = formContext.getAttribute('productid').getValue();
        var PrecioUnidadBrutoValor = 0;
   
        if(productoLookup != null)
        {debugger;
            var producto = productoLookup[0].id.slice(1, -1);
            Xrm.WebApi.online.retrieveRecord("product", ""+producto+"", "?$select=price").then(
                function success(result) {
                    PrecioUnidadBrutoValor = result["price"];
                    debugger;
                    if(PrecioUnidadBrutoValor!=null)
                    {
                        formContext.getAttribute("sing_precioporunidadbruto").setValue(PrecioUnidadBrutoValor);
   
                        if (TipoVentaValor == 321130000)
                        {
                            formContext.getControl("sing_descuento").setVisible(true);
                            if (PrecioUnidadValor == PrecioUnidadBrutoValor) {
                                Valor = 0;
                                Descuento.setValue(Valor);
                            }
                            else {
                                Valor = 100 - ((PrecioUnidadValor / PrecioUnidadBrutoValor) * 100);
                                Descuento.setValue(Valor);
                            }
                        }
                        else
                        {
                            formContext.getControl("sing_descuento").setVisible(false);
                        }
                    }
                    else
                        alert("El producto seleccionado no tiene establecido un Precio Bruto. Asigne un precio bruto y repita la operación");
                },
                function(error) {
                    Xrm.Utility.alertDialog("Consola: " + error.message);
                }
            );
        }
    }

    this.Guardar = function (executionContext)
    {debugger;
        var formContext = executionContext.getFormContext();
        var CantidadCPM = formContext.getAttribute("sing_cantidad");
        var lookupUnidad = new Array();
        lookupUnidad[0] = new Object();
        lookupUnidad[0].id = "{666edea5-78ff-4212-9670-8bac118b865f}";
        lookupUnidad[0].name = "Unidad principal";
        lookupUnidad[0].entityType = "uom";
        formContext.getAttribute("uomid").setValue(lookupUnidad);
        CantidadCPM.setValue(1);
        formContext.data.save();
    }

}).call(ProductoPropuesta);

I have the same question (0)
  • Verified answer
    Steve Zhao2 Profile Picture
    on at
    RE: Script error: Web resource method does not exist:

    Hi Shiongo,

    There is a syntax error in this line:

    formContext.getAttribute("websiteurl").setValue("">https://www.contoso.com");

    Modify it and then re-upload should be ok.

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Script error: Web resource method does not exist:

    Hi,

    You can use below online tool to validate your javascript syntax

    esprima.org/.../validate.html

  • Shiongo Profile Picture
    107 on at
    RE: Script error: Web resource method does not exist:

    pastedimage1668777369626v1.png

    Its validated, but i still getting the error

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Script error: Web resource method does not exist:

    Hi,

    Then it has something to do with namespace.

    Can you please try without namespace once.

    Normal function code

    function xyz(executionContext)

    {

    }

    Also, please specify function name when you configure event handler

    In my case it should be xyz only without bracket

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 83 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 57 Most Valuable Professional

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 52 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans