Here is the example to create CrmService:
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "org1";
token.AuthenticationType = 0; //Active directory
token.CallerId = userGuid; // impersonate to this user
CrmService pService = new CrmService();
pService.Url = _strServerUrl + "/MSCRMServices/2007/crmservice.asmx";
pService.CrmAuthenticationTokenValue = token;
pService.Credentials = DefaultCredential();
i can create crmService from two type
1. CrmService as web service from mscrmservices\2007
2. Microsoft.Crm.SDK.
to change the callerid i failed to do it if i used Crmservice from webservice.
i test the issue and changing the caller works only if Crmservice from type Microsoft.Crm.Sdk.
thanks,
Rami Heleg,
NetusUp Inc.
This site helps you to develop in the easy way Microsoft Dynamics CRM. Microsoft Dynamics CRM includes many examples to develop for Microsoft Dynamics CRM.
Showing posts with label CrmService. Show all posts
Showing posts with label CrmService. Show all posts
Monday, July 5, 2010
Monday, September 21, 2009
RetrieveMultipleResponse - Query example.
Example of query on server side.
//Create Condition.. can be many conditions + type of operator
ConditionExpression[] conditions = new ConditionExpression[1];
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = fullname;
condition.Operator = ConditionOperator.Equal;
condition.Values = new object[] { "Rami Heleg" };
conditions[i] = condition;
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = conditions;
QueryExpression query = new QueryExpression();
//Entity name
query.EntityName = "contact";
//allow to define specific columns
query.ColumnSet = new AllColumns();
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.ReturnDynamicEntities = false;
request.Query= query ;
//run Query
RetrieveMultipleResponse response = (RetrieveMultipleResponse)pService.Execute(service, request);
//Result
response.BusinessEntityCollection.BusinessEntities;
Thanks,
Rami Heleg
//Create Condition.. can be many conditions + type of operator
ConditionExpression[] conditions = new ConditionExpression[1];
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = fullname;
condition.Operator = ConditionOperator.Equal;
condition.Values = new object[] { "Rami Heleg" };
conditions[i] = condition;
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = conditions;
QueryExpression query = new QueryExpression();
//Entity name
query.EntityName = "contact";
//allow to define specific columns
query.ColumnSet = new AllColumns();
query.Criteria = filter;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.ReturnDynamicEntities = false;
request.Query= query ;
//run Query
RetrieveMultipleResponse response = (RetrieveMultipleResponse)pService.Execute(service, request);
//Result
response.BusinessEntityCollection.BusinessEntities;
Thanks,
Rami Heleg
Thursday, September 10, 2009
Create Crm Service example based systemuser and organization
Here function to create Crm Service example for specific systemuser and organization name
public static CrmService GetCrmService(Guid callerID,string organizationName) {
CrmService rslt = new CrmService();
rslt.Url = "http://localhost:5555/MSCRMServices/2007/CrmService.asmx";
CrmServiceSdk.CrmAuthenticationToken token = new CrmServiceSdk.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = organizationName;
token.CallerId = callerID;
rslt.CrmAuthenticationTokenValue = token;
rslt.Credentials =CredentialCache.DefaultCredentials;
return rslt;
}
Enjoy,
Rami Heleg
public static CrmService GetCrmService(Guid callerID,string organizationName) {
CrmService rslt = new CrmService();
rslt.Url = "http://localhost:5555/MSCRMServices/2007/CrmService.asmx";
CrmServiceSdk.CrmAuthenticationToken token = new CrmServiceSdk.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = organizationName;
token.CallerId = callerID;
rslt.CrmAuthenticationTokenValue = token;
rslt.Credentials =CredentialCache.DefaultCredentials;
return rslt;
}
Enjoy,
Rami Heleg
Create CrmService example
here function to create crmService based organization Name.
public static CrmService GetCrmService(string organizationName) {
CrmService rslt = new CrmService();
rslt.Url = "http://localhost:5555/MSCRMServices/2007/CrmService.asmx";
CrmServiceSdk.CrmAuthenticationToken token = new CrmServiceSdk.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = organizationName;
rslt.CrmAuthenticationTokenValue = token;
rslt.Credentials =CredentialCache.DefaultCredentials;
return rslt;
}
Enjoy,
Rami heleg
public static CrmService GetCrmService(string organizationName) {
CrmService rslt = new CrmService();
rslt.Url = "http://localhost:5555/MSCRMServices/2007/CrmService.asmx";
CrmServiceSdk.CrmAuthenticationToken token = new CrmServiceSdk.CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = organizationName;
rslt.CrmAuthenticationTokenValue = token;
rslt.Credentials =CredentialCache.DefaultCredentials;
return rslt;
}
Enjoy,
Rami heleg
Saturday, July 4, 2009
Get Incident Details via Javascript
Hi,
here is an example to get incident details from server only from javascript side
function GetIncidentDetails(IncidentId) {
var xml = "" +
"" +
GenerateAuthenticationHeader() +
"" +
"" +
"" +
"" + "incident" + " " +
"" +
" " +
"false " +
"" +
"And " +
"" + "incidentid Equal " + incidentId + " " +
" " +
" " +
" " +
" " +
" " +
"";
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;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities");
return entityNode;
}
Enjoy,
Rami Heleg.
here is an example to get incident details from server only from javascript side
function GetIncidentDetails(IncidentId) {
var xml = "" +
"
GenerateAuthenticationHeader() +
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"";
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;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities");
return entityNode;
}
Enjoy,
Rami Heleg.
Get Contact Details from Javascript
function GetContactDetails(contactId) {
var xml = "" +
"" +
GenerateAuthenticationHeader() +
"" +
"" +
"" +
"" + "contact" + " " +
"" +
" " +
"false " +
"" +
"And " +
"" + "contactid Equal " + contactId + " " +
" " +
" " +
" " +
" " +
" " +
"";
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;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities");
return entityNode;
}
var xml = "" +
"
GenerateAuthenticationHeader() +
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"";
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;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities");
return entityNode;
}
Subscribe to:
Posts (Atom)