Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error with getClientURL()

Posted on by 105

Hey pals i triying to do this request, but i only get this message: 

"message":"The $filter expression must evaluate to a single boolean value.","innererror":

this my function

function CopiarGestion(executionContext)
{
    debugger;
    var formContext = executionContext ? executionContext.getFormContext() : Xrm.Page; // get formContext
    var cedula = formContext.getAttribute("mme_numeroidentificacion").getValue();

    if (cedula != null) {

        var serverUrl = formContext.context.getClientUrl();
        var oDataSelect = serverUrl + "/api/data/v8.2/mme_contactcenters?" +
									  "$select=mme_tipodellamada,mme_habeasdata,mme_tipodeidentificacionpersonal,mme_numeroidentificacion," +
									    	"mme_nombrecompleto,mme_empresaentidad,mme_nit,mme_sectorempresa,mme_mme_telefonocelular," +
											"mme_telefonofijo,mme_correoelectronico,mme_pais,mme_departamento,mme_municipiociudad,mme_direccion" +
											"&$filter=mme_numeroidentificacion eq'" + cedula + "'&$orderby=mme_fechacreacion desc";

        var req = new XMLHttpRequest();

        req.open("GET", oDataSelect, true);
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
        req.onreadystatechange = function ()
        {
            if (this.readyState === 4)
            {
                req.onreadystatechange = null;

                if (this.status === 200)
                {
                    var results = JSON.parse(this.response);
                    var pais_value = results._mme_pais_value;
                    var pais_value_formatted = results["_mme_pais_value@OData.Community.Display.V1.FormattedValue"];
                    var pais = new Array();
                    pais[0] = new Object();
                    pais[0].id = pais_value;
                    pais[0].name = pais_value_formatted;
                    pais[0].entityType = "mme_pais";

                    var departamento_value = results._mme_departamento_value;
                    var departamento_value_formatted = results["_mme_departamento_value@OData.Community.Display.V1.FormattedValue"];
                    var departamento = new Array();
                    departamento[0] = new Object();
                    departamento[0].id = departamento_value;
                    departamento[0].name = departamento_value_formatted;
                    departamento[0].entityType = "mme_departamento";

                    var ciudadmunicipio_value = results._mme_municipiociudad_value;
                    var ciudadmunicipio_value_formatted = results["_mme_municipiociudad_value@OData.Community.Display.V1.FormattedValue"];
                    var ciudad = new Array();
                    ciudad[0] = new Object();
                    ciudad[0].id = ciudadmunicipio_value;
                    ciudad[0].name = ciudadmunicipio_value_formatted;
                    ciudad[0].entityType = "mme_municipiociudad";

                    /*DATOS BÁSICOS*/
                    var mme_tipodellamada = results.mme_tipodellamada;
                    var mme_tipodellamada_formatted = results["mme_tipodellamada@OData.Community.Display.V1.FormattedValue"];

                    var mme_habeasdata = results.mme_habeasdata;
                    var mme_habeasdata_formatted = results["mme_habeasdata@OData.Community.Display.V1.FormattedValue"];

                    var mme_tipodeidentificacionpersonal = results.mme_tipodeidentificacionpersonal;
                    var mme_tipodeidentificacionpersonal_formatted = results["mme_tipodeidentificacionpersonal@OData.Community.Display.V1.FormattedValue"];

                    var mme_numeroidentificacion = results.mme_numeroidentificacion;
                    var mme_nombrecompleto = results.mme_nombrecompleto;
                    var mme_nit = results.mme_nit;

                    var mme_sectorempresa = results.mme_sectorempresa;
                    var mme_sectorempresa_formatted = results["mme_sectorempresa@OData.Community.Display.V1.FormattedValue"];


                    /*DATOS COMPLEMENTARIOS*/
                    var mme_mme_telefonocelular = results.mme_mme_telefonocelular;
                    var mme_telefonofijo = results.mme_telefonofijo;
                    var mme_correoelectronico = results.mme_correoelectronico;
                    var mme_direccion = results.mme_direccion;


                    //ASIGNACION
                    if (mme_tipodellamada_formatted != null) { formContext.getAttribute("mme_tipodellamada").setValue(mme_tipodellamada_formatted); } else { mme_tipodellamada = ""; }
                    if (mme_habeasdata_formatted != null) { formContext.getAttribute("mme_habeasdata").setValue(mme_habeasdata_formatted); } else { mme_habeasdata_formatted = ""; }
                    if (mme_tipodeidentificacionpersonal_formatted != null) { formContext.getAttribute("mme_tipodeidentificacionpersonal").setValue(mme_tipodeidentificacionpersonal_formatted); } else { mme_tipodeidentificacionpersonal_formatted = ""; }

                    if (mme_numeroidentificacion != null) { formContext.getAttribute("mme_numeroidentificacion").setValue(mme_numeroidentificacion); } else { mme_numeroidentificacion = ""; }
                    if (mme_nombrecompleto != null) { formContext.getAttribute("mme_nombrecompleto").setValue(mme_nombrecompleto); } else { mme_nombrecompleto = ""; }
                    if (mme_nit != null) { formContext.getAttribute("mme_nit").setValue(mme_nit); } else { mme_nit = ""; }

                    if (mme_sectorempresa_formatted != null) { formContext.getAttribute("mme_sectorempresa").setValue(mme_sectorempresa_formatted); } else { mme_sectorempresa_formatted = ""; }

                    if (mme_mme_telefonocelular != null) { formContext.getAttribute("mme_mme_telefonocelular").setValue(mme_mme_telefonocelular); } else { mme_mme_telefonocelular = ""; }
                    if (mme_telefonofijo != null) { formContext.getAttribute("mme_telefonofijo").setValue(mme_telefonofijo); } else { mme_telefonofijo = ""; }
                    if (mme_correoelectronico != null) { formContext.getAttribute("mme_correoelectronico").setValue(mme_correoelectronico); } else { mme_correoelectronico = ""; }
                    if (mme_direccion != null) { formContext.getAttribute("mme_direccion").setValue(mme_direccion); } else { mme_direccion = ""; }

                    if (pais != null) { formContext.getAttribute("mme_pais").setValue(pais); } else { pais = ""; }
                    if (departamento != null) { formContext.getAttribute("mme_departamento").setValue(departamento); } else { departamento = ""; }
                    if (ciudad != null) { formContext.getAttribute("mme_municipiociudad").setValue(ciudad); } else { ciudad = ""; }
                }
                else
                {
                    formContext.ui.setFormNotification(this.statusText, "WARNING", "2");
                }
            }
        };
        req.send();
    }
    else
    {
        formContext.getAttribute("mme_tipodellamada").setValue(null);
        formContext.getAttribute("mme_habeasdata").setValue(null);
        formContext.getAttribute("mme_tipodeidentificacionpersonal").setValue(null);
        formContext.getAttribute("mme_numeroidentificacion").setValue(null);
        formContext.getAttribute("mme_nombrecompleto").setValue(null);
        formContext.getAttribute("mme_nit").setValue(null);
        formContext.getAttribute("mme_pais").setValue(null);
        formContext.getAttribute("mme_departamento").setValue(null);
        formContext.getAttribute("mme_municipiociudad").setValue(null);
        formContext.getAttribute("mme_sectorempresa").setValue(null);
        formContext.getAttribute("mme_mme_telefonocelular").setValue(null);
        formContext.getAttribute("mme_telefonofijo").setValue(null);
        formContext.getAttribute("mme_correoelectronico").setValue(null);
        formContext.getAttribute("mme_direccion").setValue(null);
    }
}
Any suggestions? Thanks

*This post is locked for comments

  • Suggested answer
    naresh babu Profile Picture
    naresh babu 425 on at
    RE: Error with getClientURL()

    Hi Shiongo,
    Go throw below blogs:

    To get more than 50 records records through Odata Services

    https://dynamicscrmscript.blogspot.com/


    First try to get the data without filter conditions.
    Second use filter conditions.
     

  • Shiongo Profile Picture
    Shiongo 105 on at
    RE: Error with getClientURL()

    I cant do it, the error is the folowing

    {
      "error":{
        "code":"","message":"The $filter expression must evaluate to a single boolean value.","innererror":{
          "message":"The $filter expression must evaluate to a single boolean value.","type":"Microsoft.OData.Core.ODataException","stacktrace":"   en Microsoft.OData.Core.UriParser.Parsers.FilterBinder.BindFilter(QueryToken filter)\r\n   en Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilterImplementation(String filter, ODataUriParserConfiguration configuration, IEdmType elementType, IEdmNavigationSource navigationSource)\r\n   en Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseFilter()\r\n   en System.Web.OData.Query.FilterQueryOption.get_FilterClause()\r\n   en Microsoft.Crm.Extensibility.OData.DataQueryOptionsConverter.SetFilterExpression(QueryExpression qe, FilterQueryOption filterQueryOption)\r\n   en Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context)\r\n   en Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, String castedEntityName, ODataQueryOptions queryOptions)\r\n   en Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n   en Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\r\n   en lambda_method(Closure , Object , Object[] )\r\n   en System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   en System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- Fin del seguimiento de la pila de la ubicaci\u00f3n anterior donde se produjo la excepci\u00f3n ---\r\n   en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   en System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicaci\u00f3n anterior donde se produjo la excepci\u00f3n ---\r\n   en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   en System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- Fin del seguimiento de la pila de la ubicaci\u00f3n anterior donde se produjo la excepci\u00f3n ---\r\n   en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   en System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
        }
      }
    }


    i do this change

        var cedula = parseInt(formContext.getAttribute("mme_numeroidentificacion").getValue());
    
        if (cedula != null) {
    
            var serverUrl = formContext.context.getClientUrl();
            var oDataSelect = serverUrl + "/api/data/v8.2/mme_contactcenters?$select=mme_tipodellamada,mme_habeasdata,mme_tipodeidentificacionpersonal,mme_numeroidentificacion,mme_nombrecompleto,mme_empresaentidad,mme_nit,mme_sectorempresa,mme_mme_telefonocelular,mme_telefonofijo,mme_correoelectronico,mme_pais,mme_departamento,mme_municipiociudad,mme_direccion&$filter=mme_numeroidentificacion eq '"+cedula.toString()+"'&$orderby=mme_fechacreacion desc";
    
    
            var req = new XMLHttpRequest();
    
            req.open("GET", oDataSelect, false);


  • Verified answer
    naresh babu Profile Picture
    naresh babu 425 on at
    RE: Error with getClientURL()

    Have you used debugger;

    if yes, Please post you results or error also

  • Sreevalli Profile Picture
    Sreevalli 3,256 on at
    RE: Error with getClientURL()

    Hi,

    "cedula" not in expected format (I think), debug for "oDataSelect" and paste the result in browser, you can add select and filter if all goes well then add order to see spot the issues.

  • Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Error with getClientURL()

    mme_numeroidentificacion should return a string. Debug the script. and see what you see. you can do

    cedula.toString(); and use it in the url.

    also you can try to do orderby first and then filter.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans