Sprawdzenie ilości utworzonych dzisiaj kont (account) niezależnie od CRM-a
Poniżej znajduje się kod który umożliwia sprawdzenie w dzisiejszym dniu jakie konta zostały dodane do CRM-a bez potrzeby nawet otwierania CRM-a.
Całą poniższą zawartość kopiujemy do jednego pliku HTML, warunkiem jest to by być zalogowanym do CRM-a. Należy zmienić adresy serwera oraz nazwę organizacji.
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>Access CRM Web Services</title>
<SCRIPT language=”JavaScript”>
function AccessCRMWebServices()
{
// Tutaj należy zmienić adres serwera CRM 4.0
var serverUrl = “http://191.168.1.5:5555/mscrmservices/2007“;
var xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
xmlhttp.open(”POST”, serverUrl + “/crmservice.asmx”, false);
xmlhttp.setRequestHeader(”Content-Type”, “text/xml; charset=utf-8″)
xmlhttp.setRequestHeader(”SOAPAction”, “http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple“)
xmlhttp.send(”<?xml version=’1.0′ encoding=’utf-8′?>”+”\n\n”+”<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:Header>’ +
‘ <CrmAuthenticationToken xmlns=\”http://schemas.microsoft.com/crm/2007/WebServices\”>’ +
‘ <AuthenticationType xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>0</AuthenticationType>’ +
‘ <OrganizationName xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>nazwa_organizacji</OrganizationName>’ +
‘ <CallerId xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>00000000-0000-0000-0000-000000000000</CallerId>’ +
‘ </CrmAuthenticationToken>’ +
‘ </soap:Header>’ +
‘ <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:AllColumns\” />’ +
‘ <q1:Distinct>false</q1:Distinct>’ +
‘ <q1:Criteria>’ +
‘ <q1:FilterOperator>And</q1:FilterOperator>’ +
‘ <q1:Conditions>’ +
‘ <q1:Condition>’ +
‘ <q1:AttributeName>createdon</q1:AttributeName>’ +
‘ <q1:Operator>Today</q1:Operator>’ +
‘ </q1:Condition>’ +
‘ </q1:Conditions>’ +
‘ </q1:Criteria>’ +
‘ </query>’ +
‘ </RetrieveMultiple>’ +
‘ </soap:Body>’ +
‘</soap:Envelope>’)
var result = xmlhttp.responseXML;
var entityNodes= result.selectNodes(”//RetrieveMultipleResult/BusinessEntities/BusinessEntity”);
for (var i = 0; i < entityNodes.length; i++) {
var entityNode = entityNodes[i];
var accountid = entityNode.selectSingleNode(”q1:accountid”);
var name = entityNode.selectSingleNode(”q1:name”);
//Po pobraniu wyświetlamy nazwę konta oraz link prowadzący do edycji konta
document.writeln(”<a href=\”http://192.1168.1.5:5555/sfa/accts/edit.aspx?id=” + accountid.text + “\” target=\”new\”><font size=\”1px\”" + “name=\”verdana\”>” + name.text + “</font></a><hr>”);
}
}
</SCRIPT>
</head>
<body bgcolor=”#eff3f7″>
<script language=”JavaScript” type=”text/javascript”>
AccessCRMWebServices() ;
</script>
</body>
</html>
