简体   繁体   中英

ReferenceError in Dynamics 365 Webresource

I am using web resource in CRM of Dynamics 365. Recently, such an error occurred, and I didn't know why it happened and I asked a question.

Error log content:

ReferenceError: $ is not defined

I'll attach the part where the error log appears.

function setSerialnoinfo(){
var serialno = Xrm.Page.data.entity.attributes.get("skr_serialno");

if(Xrm.Page.getAttribute("skr_serialno").getValue() != null){

    var serialnoid = serialno.getValue()[0].id;
    var query = "/skr_installationSet(guid'"+serialnoid+"')";
        $.ajax({
        type: "GET",
        async : false,
        contentType: "application/json; charset=utf-8", 
        datatype: "json", 
        url: "/XRMServices/2011/OrganizationData.svc"+query,
        beforeSend: function (XMLHttpRequest) { 
            XMLHttpRequest.setRequestHeader("Accept", "application/json"); 
        }, 
        success: function(data, textStatus, XmlHttpRequest) {
            var result = data.d;

                var skr_productid = result.skr_product.Id;
                var skr_productname = result.skr_product.Name;
                var skr_productentity = result.skr_product.LogicalName;

                if (!(skr_productid == null || skr_productid == "")){
                    Xrm.Page.data.entity.attributes.get("skr_product").setValue([{id: skr_productid, name: skr_productname, entityType: skr_productentity}]);           
                }
                //var skr_salestype = result.skr_salestype.Value;
                var skr_warrantytype = result.skr_warrantytype.Value;

                if(skr_warrantytype == 1){
                    skr_warrantytype = 0;
                }

                Xrm.Page.data.entity.attributes.get("skr_servicefeetype").setValue(skr_warrantytype);

                var skr_servicecontracttype   = result.skr_servicecontracttype.Value;
                Xrm.Page.data.entity.attributes.get("skr_servicecontracttype").setValue(skr_servicecontracttype);

                var skr_modelid = result.skr_model.Id;
                var skr_modelname = result.skr_model.Name;
                var skr_modelentity = result.skr_model.LogicalName;

                if (!(skr_modelid == null || skr_modelid == "")){
                    Xrm.Page.data.entity.attributes.get("skr_setname").setValue([{id: skr_modelid, name: skr_modelname, entityType: skr_modelentity}]); 
                    setsetname();
                    setErrorModel();
                }

                Xrm.Page.getAttribute("skr_product").setSubmitMode("always"); 
                Xrm.Page.getAttribute("skr_servicefeetype").setSubmitMode("always"); 
                Xrm.Page.getAttribute("skr_setname").setSubmitMode("always"); 
                Xrm.Page.getAttribute("skr_servicecontracttype").setSubmitMode("always"); 
                Xrm.Page.getAttribute("skr_productseries").setSubmitMode("always"); 


        }, 
        error: function (XMLHttpRequest, textStatus, errorThrown) { 
                var userlcid = Xrm.Page.context.getUserLcid();
            if(userlcid == "1042"){
                alert("오류가 발생 했습니다. 다시 시도해 주세요."); 
            }else if(userlcid == "1033"){
                alert("Unknown Error: Try again."); 
            }           
        }
        });
}
}

This is an error in testing with the user's new UI version before Microsoft's 10 update.

I also want to know if the grammar of web resource changes a little after the update.

You are using jQuery library in your web resource, somehow the link is broken or conflict happening.

  1. Validate you are adding/loading jquery.js or jquery.min.js in your HTML . Check entity form before this function residing library being referred - this is unsupported for this very same broken behavior
  2. Otherwise if you are relying on native library reference, rather add your own library reference like above & use jQuery.noConflict() . Read more
  3. Stick with XMLHttpRequest for supported scope & most important Xrm.Page is deprecated , pls start using the ExecutionContext.getFormContext

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM