public Entity GetOrderDetails(Guid OrderID)
{
ClientCredentials Credentials = new ClientCredentials();
Credentials.UserName.UserName = "UserName";
Credentials.UserName.Password = "Password";
//Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Uri organizationURI = new Uri("Organization uri");
OrganizationServiceProxy serviceproxy = new OrganizationServiceProxy(organizationURI, null, Credentials, null);
orgservice = (IOrganizationService)serviceproxy;
Entity OrdersEntity = null;
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "salesorderid";
condition.Operator = ConditionOperator.Equal;
condition.Values.Add(OrderID);
ColumnSet columns = new ColumnSet(true);
QueryExpression expression = new QueryExpression();
expression.EntityName = "salesorder";
expression.ColumnSet = columns;
expression.Criteria.AddCondition(condition);
EntityCollection opportunityEntityColl = orgservice.RetrieveMultiple(expression);
if (opportunityEntityColl.Entities.Count > 0)
{
OrdersEntity = opportunityEntityColl.Entities[0];
}
return OrdersEntity;
}
{
ClientCredentials Credentials = new ClientCredentials();
Credentials.UserName.UserName = "UserName";
Credentials.UserName.Password = "Password";
//Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
Uri organizationURI = new Uri("Organization uri");
OrganizationServiceProxy serviceproxy = new OrganizationServiceProxy(organizationURI, null, Credentials, null);
orgservice = (IOrganizationService)serviceproxy;
Entity OrdersEntity = null;
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "salesorderid";
condition.Operator = ConditionOperator.Equal;
condition.Values.Add(OrderID);
ColumnSet columns = new ColumnSet(true);
QueryExpression expression = new QueryExpression();
expression.EntityName = "salesorder";
expression.ColumnSet = columns;
expression.Criteria.AddCondition(condition);
EntityCollection opportunityEntityColl = orgservice.RetrieveMultiple(expression);
if (opportunityEntityColl.Entities.Count > 0)
{
OrdersEntity = opportunityEntityColl.Entities[0];
}
return OrdersEntity;
}
No comments:
Post a Comment