none
Check Codice Fiscale

    Domanda

  • Salve a tutti, ho un CRM 4.0 Enterprise con 2 organizzazioni installate: MS01 e MS02
    Ora.. con lo script qui sotto riportato, in Account, ho creato uno script On Change su account_number per verificare che non esista un altro codice fiscale ( qui dove vivo, all'estero, si chiama RUT, uguale al momento dell'inserimento del account..

    Ora sull'organizzazione di default funzione, sull'altra fá la ricerca sul DB sbagliato ( quello dell'organizazione predefinita )
    Mi hanno detto  che dovrei passare dall'endpoint 2006 al 2007! Corretto? Ma come? é sufficiente che interroghi lo stesso webservices pero nella cartella 2007? ( in soldoni rimpiazzo 2006 - 2007 ) o che?



    function Existe(sRut)
    {
    /*Agregado para no ingresar de nuevo un rut */
    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
    " <soap:Body>" +
    "    <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
    "      <q1:EntityName>account</q1:EntityName>" +
    "      <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
    "             <q1:Attributes>" +
    "                    <q1:Attribute>accountid</q1:Attribute>" +
    "                    <q1:Attribute>accountnumber</q1:Attribute>" +
    "              </q1:Attributes>" +
    "      </q1:ColumnSet>" +
    '      <q1:Distinct>true</q1:Distinct>' +
    '      <q1:Criteria>' +
    '             <q1:FilterOperator>And</q1:FilterOperator>' +
    '             <q1:Conditions>' +
    '                    <q1:Condition>'+
    '                           <q1:AttributeName>accountnumber</q1:AttributeName>' +
    '                           <q1:Operator>Equal</q1:Operator>' +
    '                           <q1:Values>' +
    '                                  <q1:Value xsi:type="xsd:string">'+sRut+'</q1:Value>'+
    '           </q1:Values>' +
    '                    </q1:Condition>' +
    '             </q1:Conditions>' +
    '      </q1:Criteria>'+
    '    </query>' +
    '  </soap:Body>' +
    '</soap:Envelope>'


     var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
     xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
     xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
     xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
     xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
     xmlHttpRequest.send(xml);

     var resultXml = xmlHttpRequest.responseXML;
     var result = resultXml .xml;
     var BEs= result.split("<BusinessEntities>");

     if(BEs.length > 1)
     {
        alert("El Rut " + crmForm.all.accountnumber.value + " ya existe en la base de datos.");
        crmForm.all.accountnumber.DataValue=null;
        crmForm.all.accountnumber.SetFocus();

     }

    }
    giovedì 29 ottobre 2009 19:32

Risposte

  • Ciao Alessandro,
    prova con questo codice:

        var xml = "" +
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
     GenerateAuthenticationHeader() +
     " <soap:Body>" +
     " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
     " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" +
     " <q1:EntityName>account</q1:EntityName>" +
     <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
    "             <q1:Attributes>" +
    "                    <q1:Attribute>accountid</q1:Attribute>" +
    "                    <q1:Attribute>accountnumber</q1:Attribute>" +
    "              </q1:Attributes>" +
    "      </q1:ColumnSet>" + 
    "      <q1:Distinct>true</q1:Distinct>" + 
    "<q1:Criteria>" +
    "             <q1:FilterOperator>And</q1:FilterOperator>" +
    "             <q1:Conditions>" +
    "                    <q1:Condition>"+
    "                           <q1:AttributeName>accountnumber</q1:AttributeName>" +
    "                           <q1:Operator>Equal</q1:Operator>" +
    "                           <q1:Values>" +
    "                                  <q1:Value xsi:type="xsd:string">"+sRut+"</q1:Value>"+
    "           </q1:Values>" +
    "                    </q1:Condition>" +
    "             </q1:Conditions>" +
    "      </q1:Criteria>"+
     " </query>" +
     " </RetrieveMultiple>" +
     " </soap:Body>" +
     "</soap:Envelope>" +
     "";

        var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xmlHttpRequest.setRequestHeader("SOAPAction", " http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
        xmlHttpRequest.send(xml);

        var resultXml = xmlHttpRequest.responseXML;
        return (resultXml);
    --------------------------------------
    ho inserito la tua query, dovrebbe quindi già essere funzionante.
    Fammi sapere.

    in bold ho segnato le due parti che servono per l'end point del CRM4.0

    Grazie. ciao
    Roberto


    Roberto Nocera [Microsoft Dynamics CRM MVP] technical blog: http://blogs.ugidotnet.org/rnocera/ Community CRM italiana: www.dynamicsforum.it
    lunedì 9 novembre 2009 15:12
    Moderatore

Tutte le risposte

  • Ciao Alessandro,
    prova con questo codice:

        var xml = "" +
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
     GenerateAuthenticationHeader() +
     " <soap:Body>" +
     " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
     " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" +
     " <q1:EntityName>account</q1:EntityName>" +
     <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
    "             <q1:Attributes>" +
    "                    <q1:Attribute>accountid</q1:Attribute>" +
    "                    <q1:Attribute>accountnumber</q1:Attribute>" +
    "              </q1:Attributes>" +
    "      </q1:ColumnSet>" + 
    "      <q1:Distinct>true</q1:Distinct>" + 
    "<q1:Criteria>" +
    "             <q1:FilterOperator>And</q1:FilterOperator>" +
    "             <q1:Conditions>" +
    "                    <q1:Condition>"+
    "                           <q1:AttributeName>accountnumber</q1:AttributeName>" +
    "                           <q1:Operator>Equal</q1:Operator>" +
    "                           <q1:Values>" +
    "                                  <q1:Value xsi:type="xsd:string">"+sRut+"</q1:Value>"+
    "           </q1:Values>" +
    "                    </q1:Condition>" +
    "             </q1:Conditions>" +
    "      </q1:Criteria>"+
     " </query>" +
     " </RetrieveMultiple>" +
     " </soap:Body>" +
     "</soap:Envelope>" +
     "";

        var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

        xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
        xmlHttpRequest.setRequestHeader("SOAPAction", " http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
        xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
        xmlHttpRequest.send(xml);

        var resultXml = xmlHttpRequest.responseXML;
        return (resultXml);
    --------------------------------------
    ho inserito la tua query, dovrebbe quindi già essere funzionante.
    Fammi sapere.

    in bold ho segnato le due parti che servono per l'end point del CRM4.0

    Grazie. ciao
    Roberto


    Roberto Nocera [Microsoft Dynamics CRM MVP] technical blog: http://blogs.ugidotnet.org/rnocera/ Community CRM italiana: www.dynamicsforum.it
    lunedì 9 novembre 2009 15:12
    Moderatore
  • Grazie mille, lo proveró certamente,
    al momento ho risolto creandomi una webapp aspx per generarmi un XML..

    Cmq proveró a integrarla subito
    martedì 17 novembre 2009 13:05