16 Aralık 2015 Çarşamba
CRM Versiyon Alma ( Retrieve the current CRM version)
public enum CRMVersion
{
Unknown,
CRM2011,
CRM2011UR12PLUS,
CRM2013,
CRM2013SP1,
CRM2015
}
public CRMVersion GetCRMVersion(IOrganizationService service)
{
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)service.Execute(versionRequest);
string version = versionResponse.Version;
if (version.StartsWith("5"))
{
try
{
int buildNumber = Convert.ToInt32(version.Substring(version.LastIndexOf(".") + 1));
if (buildNumber > 3000) { return CRMVersion.CRM2011UR12PLUS; }
}
catch { }
return CRMVersion.CRM2011;
}
if (version.StartsWith("6.0")) { return CRMVersion.CRM2013; }
if (version.StartsWith("6.1")) { return CRMVersion.CRM2013SP1; }
if (version.StartsWith("7")) { return CRMVersion.CRM2015; }
return CRMVersion.Unknown;
}
15 Aralık 2015 Salı
14 Aralık 2015 Pazartesi
10 Aralık 2015 Perşembe
CRM 2011 - Gelişmiş Bul 'da Her Sayfada Görünecek Kayıt Sayısını Değiştirme (Change the number of records per page in any list of records)
Aşağıdaki yazımda Gelişmiş Bul ;'da yapılan sorgulamada her sayfa için 50 adet kayıt listeleniyordu. Ben bunu her sayfada 250 kayıt gelecek şekilde değiştireceğim.
CRM ana ekranında File butonuna tıklayalım. Gelen seçeneklerden Options a tıklayalım.
Set Personal Options penceresinde General tabının altından Set the number of records per page in any list of records kısmından her sayfada kaç adet kayıt geleceğini seçelim.Ok butonuna basalım.
50 olan seçeneği 250 olarak değiştirelim..
Seçeneğimi 250 olarak değiştirdikten sonra Ok butonuna basalım.
Gelişmiş Bul 'u açalım ve ekranda 250 kayıt görelim.
CRM 2011 - Kullanıcı TimeZone Ayarları (CurrentUser Timezone Settings)
CRM ana ekranında File butonuna tıklayalım. Gelen seçeneklerden Options a tıklayalım.
Set Personal Options penceresinde General tabının altından Set the time zone you are in kısmından Time Zone u seçelim.Ok butonuna basalım.
Set Personal Options penceresinde General tabının altından Set the time zone you are in kısmından Time Zone u seçelim.Ok butonuna basalım.
CRM 2011 QueryExpresison - Kullanıcı TimeZone Ayarları Çekme ( Retrive Current User TimeZone Settings)
public static UserSettings GetCurrentUsersTimeZoneSettings(IOrganizationService crmService, Guid userid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("usersettings", "systemuserid", userid, columnset);
EntityCollection ec = crmService.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (UserSettings)ec.Entities[0];
else
return new UserSettings();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
UserSettings abc = CrmManagerStatic.GetCurrentUsersTimeZoneSettings(crmService, new Guid("D91E53ED-4AC1-E211-87D1-0050569505A4"), new ColumnSet("localeid", "timezonebias", "timezonecode"));
if (abc != null && abc.Id != Guid.Empty){
}
CRM 2011 Plugin - Merge Plugin Yazımı
Bu makalemde iki contact varlığının merge edildiğinde çalışacak pluginin nasıl yazılacağını anlatacağım.
Merge plugini yazımında context ten bize Target ve SubordinateId diye tanımlı InputParameterelere dikkat edeceğiz.Target parametresi bize geriye kalcak varlığın bilgisini verirken , SubordinateId parametresi bize deactivate olacak ikinci varlığın bilgisini verir.
Aşağıdaki kodları incelerseniz beni daha ii anlayacaksınız.
contact1 nesnesi işlem sonunda geriye kalan contact ı
contact2 ise deactivate olan contactı simgeler.
Kaynak Kodlar
public class ContactMerge : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
Guid contact1 = Guid.Empty;
Guid contact2 = Guid.Empty;
try
{
#region Plugin Tanımlamaları
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
serviceFactory.GetType().GetProperty("ProxyTypesAssembly").SetValue(serviceFactory, typeof(XrmServiceContext).Assembly, null);
IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId);
if (!context.InputParameters.Contains("Target"))
return;
if (string.IsNullOrEmpty(context.MessageName))
return;
if (!context.MessageName.Equals("Merge"))
throw new Exception("Plugin executed but message was not merge");
#endregion
#region Main Code
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
{
EntityReference eTarget = (EntityReference)context.InputParameters["Target"];
contact1 = eTarget.Id;
contact2 = (Guid)context.InputParameters["SubordinateId"];
if (contact1 != Guid.Empty && contact2 != Guid.Empty)
{
Contact contact1Entity = (Contact)crmService.Retrieve("contact", contact1, new ColumnSet(new string[] { "contactid", "ite_industryid" }));
if (contact1Entity != null && contact1Entity.Id != Guid.Empty)
{
}
else
throw new Exception("Contact not found.");
}
else
throw new Exception("Contact1 or Contact2 id guid empty.");
}
else
throw new Exception("Not right type of target");
#endregion
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("An error occurred in the ContactMerge plug-in" + ex.Message);
}
}
}
Plugin Registration Tool ile MErge Plugin Deploy Etme
Plugin inize aşağıdaki step i eklemeniz yeterli olacaktır.
Merge plugini yazımında context ten bize Target ve SubordinateId diye tanımlı InputParameterelere dikkat edeceğiz.Target parametresi bize geriye kalcak varlığın bilgisini verirken , SubordinateId parametresi bize deactivate olacak ikinci varlığın bilgisini verir.
Aşağıdaki kodları incelerseniz beni daha ii anlayacaksınız.
contact1 nesnesi işlem sonunda geriye kalan contact ı
contact2 ise deactivate olan contactı simgeler.
Kaynak Kodlar
public class ContactMerge : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
Guid contact1 = Guid.Empty;
Guid contact2 = Guid.Empty;
try
{
#region Plugin Tanımlamaları
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
serviceFactory.GetType().GetProperty("ProxyTypesAssembly").SetValue(serviceFactory, typeof(XrmServiceContext).Assembly, null);
IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId);
if (!context.InputParameters.Contains("Target"))
return;
if (string.IsNullOrEmpty(context.MessageName))
return;
if (!context.MessageName.Equals("Merge"))
throw new Exception("Plugin executed but message was not merge");
#endregion
#region Main Code
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is EntityReference)
{
EntityReference eTarget = (EntityReference)context.InputParameters["Target"];
contact1 = eTarget.Id;
contact2 = (Guid)context.InputParameters["SubordinateId"];
if (contact1 != Guid.Empty && contact2 != Guid.Empty)
{
Contact contact1Entity = (Contact)crmService.Retrieve("contact", contact1, new ColumnSet(new string[] { "contactid", "ite_industryid" }));
if (contact1Entity != null && contact1Entity.Id != Guid.Empty)
{
}
else
throw new Exception("Contact not found.");
}
else
throw new Exception("Contact1 or Contact2 id guid empty.");
}
else
throw new Exception("Not right type of target");
#endregion
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("An error occurred in the ContactMerge plug-in" + ex.Message);
}
}
}
Plugin Registration Tool ile MErge Plugin Deploy Etme
Plugin inize aşağıdaki step i eklemeniz yeterli olacaktır.
9 Aralık 2015 Çarşamba
CRM 2011 QueryExpression - Fırsat ın Görevlerini Çekme (Get Tasks in Opportunity)
public static EntityCollection GetTasksInOpportunity(IOrganizationService crmService, Guid opportunityid, ColumnSet columnset)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "task",
ColumnSet = columnset,
NoLock = true,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("activitytypecode",ConditionOperator.Equal,4214),
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="task",
LinkFromAttributeName="regardingobjectid",
LinkToEntityName = "opportunity",
LinkToAttributeName = "opportunityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("opportunityid",ConditionOperator.Equal,opportunityid)
}
}
}
}
};
EntityCollection ec = crmService.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "task",
ColumnSet = columnset,
NoLock = true,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("activitytypecode",ConditionOperator.Equal,4214),
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="task",
LinkFromAttributeName="regardingobjectid",
LinkToEntityName = "opportunity",
LinkToAttributeName = "opportunityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("opportunityid",ConditionOperator.Equal,opportunityid)
}
}
}
}
};
EntityCollection ec = crmService.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 QueryExpression - Fırsat Ürünlerini Çekme (Get Opportunity Details)
public static EntityCollection GetOpportunityDetails(Guid opportunityid, IOrganizationService ser)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "opportunityproduct",
ColumnSet = new ColumnSet("opportunityproductid", "opportunityid"),
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="opportunityproduct",
LinkFromAttributeName="opportunityid",
LinkToEntityName = "opportunity",
LinkToAttributeName = "opportunityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "opportunityid",
Operator = ConditionOperator.Equal,
Values = { opportunityid }
}
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ec_FirsatUrunleri = Core.GetOpportunityDetails(opportunityId, crmService);
if (ec_FirsatUrunleri != null && ec_FirsatUrunleri.Entities.Count != 0)
{
foreach (var item in ec_FirsatUrunleri.Entities)
{
OpportunityProduct firsaturunu = (OpportunityProduct)item;
if (firsaturunu != null && firsaturunu.Id != Guid.Empty)
{
}
}
}
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "opportunityproduct",
ColumnSet = new ColumnSet("opportunityproductid", "opportunityid"),
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="opportunityproduct",
LinkFromAttributeName="opportunityid",
LinkToEntityName = "opportunity",
LinkToAttributeName = "opportunityid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "opportunityid",
Operator = ConditionOperator.Equal,
Values = { opportunityid }
}
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ec_FirsatUrunleri = Core.GetOpportunityDetails(opportunityId, crmService);
if (ec_FirsatUrunleri != null && ec_FirsatUrunleri.Entities.Count != 0)
{
foreach (var item in ec_FirsatUrunleri.Entities)
{
OpportunityProduct firsaturunu = (OpportunityProduct)item;
if (firsaturunu != null && firsaturunu.Id != Guid.Empty)
{
}
}
}
CRM 2011 - Retrive Kullanımı (Get Opportunity)
IOrganizationService içerisindeki Retrieve metodu ile guid si bilinen değerlere kısa yoldan ulaşabilirsiniz.
Opportunity opportunity = (Opportunity)crmService.Retrieve("opportunity", opportunityId, new ColumnSet("opportunityid", "pricelevelid", "name"));
Opportunity opportunity = (Opportunity)crmService.Retrieve("opportunity", opportunityId, new ColumnSet("opportunityid", "pricelevelid", "name"));
CRM 2011 QueryExpresion - Ek Dosyayı Çekme (Get Activity Mime Attachment)
public static EntityCollection GetActivityMimeAttachment(IOrganizationService crmService, Guid activityid, ColumnSet columnset)
{
try
{
QueryExpression _attachmentQuery = new QueryExpression
{
EntityName = ActivityMimeAttachment.EntityLogicalName,
ColumnSet = columnset,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("objectid",ConditionOperator.Equal,activityid)
}
}
};
return crmService.RetrieveMultiple(_attachmentQuery);
}
catch (Exception ex)
{
throw ex;
}
}
{
try
{
QueryExpression _attachmentQuery = new QueryExpression
{
EntityName = ActivityMimeAttachment.EntityLogicalName,
ColumnSet = columnset,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("objectid",ConditionOperator.Equal,activityid)
}
}
};
return crmService.RetrieveMultiple(_attachmentQuery);
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 - Varlığın Takımla Share İlişkisi
Aşağıdaki metot sayesinde herhangi bir kayıdın belli bir takıma share olup olmaması bulunur.
public static bool Ishared(IOrganizationService service, string entityname, Guid entityid, string teamname)
{
var isReturn = false;
var accessResponse = RetrieveAndDisplayAccess(service, entityname, entityid);
if (accessResponse != null && accessResponse.PrincipalAccesses != null && accessResponse.PrincipalAccesses.Length != 0)
{
foreach (var principalAccess in accessResponse.PrincipalAccesses)
{
if (principalAccess.Principal.LogicalName.ToLower().Equals("team"))
{
Team team = (Team)service.Retrieve("team", principalAccess.Principal.Id, new ColumnSet("teamid", "name"));
if (team != null && team.Id != Guid.Empty)
{
if (team.Name.ToLower().Equals(teamname.ToLower()))
{
isReturn = true; break;
}
}
}
}
}
return isReturn;
}
public static RetrieveSharedPrincipalsAndAccessResponse RetrieveAndDisplayAccess(IOrganizationService service, string entityname, Guid entityid)
{
var accessRequest = new RetrieveSharedPrincipalsAndAccessRequest
{
Target = new EntityReference(entityname, entityid)
};
// The RetrieveSharedPrincipalsAndAccessResponse returns an entity reference
// that has a LogicalName of "user" when returning access information for a
// "team."
return (RetrieveSharedPrincipalsAndAccessResponse)service.Execute(accessRequest);
}
Metot Kullanımı
var isShared = Core.IsShared(serv, targetName, _targetId, team.Name);
if (!isShared)
{
// Bu takımla paylasılmamıs
}
public static bool Ishared(IOrganizationService service, string entityname, Guid entityid, string teamname)
{
var isReturn = false;
var accessResponse = RetrieveAndDisplayAccess(service, entityname, entityid);
if (accessResponse != null && accessResponse.PrincipalAccesses != null && accessResponse.PrincipalAccesses.Length != 0)
{
foreach (var principalAccess in accessResponse.PrincipalAccesses)
{
if (principalAccess.Principal.LogicalName.ToLower().Equals("team"))
{
Team team = (Team)service.Retrieve("team", principalAccess.Principal.Id, new ColumnSet("teamid", "name"));
if (team != null && team.Id != Guid.Empty)
{
if (team.Name.ToLower().Equals(teamname.ToLower()))
{
isReturn = true; break;
}
}
}
}
}
return isReturn;
}
public static RetrieveSharedPrincipalsAndAccessResponse RetrieveAndDisplayAccess(IOrganizationService service, string entityname, Guid entityid)
{
var accessRequest = new RetrieveSharedPrincipalsAndAccessRequest
{
Target = new EntityReference(entityname, entityid)
};
// The RetrieveSharedPrincipalsAndAccessResponse returns an entity reference
// that has a LogicalName of "user" when returning access information for a
// "team."
return (RetrieveSharedPrincipalsAndAccessResponse)service.Execute(accessRequest);
}
Metot Kullanımı
var isShared = Core.IsShared(serv, targetName, _targetId, team.Name);
if (!isShared)
{
// Bu takımla paylasılmamıs
}
CRM 2011 Plugin - Crm Admin ile CRM Servise Bağlanma
public static IOrganizationService GetCrmServiceByCrmAdmin(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
serviceFactory.GetType().GetProperty("ProxyTypesAssembly").SetValue(serviceFactory, typeof(XrmServiceContext).Assembly, null);
return serviceFactory.CreateOrganizationService(new Guid(_settingFactory.GetCrmAdminId));
}
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
serviceFactory.GetType().GetProperty("ProxyTypesAssembly").SetValue(serviceFactory, typeof(XrmServiceContext).Assembly, null);
return serviceFactory.CreateOrganizationService(new Guid(_settingFactory.GetCrmAdminId));
}
CRM 2011 - Is Guid (REGEX)
public static bool IsGuid(this string s)
{
if (s == null)
throw new ArgumentNullException("s");
Regex format = new Regex(
"^[A-Fa-f0-9]{32}$|" +
"^({|\\()?[A-Fa-f0-9]{8}-([A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}(}|\\))?$|" +
"^({)?[0xA-Fa-f0-9]{3,10}(, {0,1}[0xA-Fa-f0-9]{3,6}){2}, {0,1}({)([0xA-Fa-f0-9]{3,4}, {0,1}){7}[0xA-Fa-f0-9]{3,4}(}})$");
Match match = format.Match(s);
return match.Success;
}
Extension Kullanımı
if (!string.IsNullOrEmpty(entityid) && entityid.IsGuid())
{
}
{
if (s == null)
throw new ArgumentNullException("s");
Regex format = new Regex(
"^[A-Fa-f0-9]{32}$|" +
"^({|\\()?[A-Fa-f0-9]{8}-([A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}(}|\\))?$|" +
"^({)?[0xA-Fa-f0-9]{3,10}(, {0,1}[0xA-Fa-f0-9]{3,6}){2}, {0,1}({)([0xA-Fa-f0-9]{3,4}, {0,1}){7}[0xA-Fa-f0-9]{3,4}(}})$");
Match match = format.Match(s);
return match.Success;
}
Extension Kullanımı
if (!string.IsNullOrEmpty(entityid) && entityid.IsGuid())
{
}
CRM 2011 - İki Varlık Arasında İlişki lup Olmadığını Bulma (RelationshipExists)
private static bool RelationshipExists(IOrganizationService service, string relationshipname, Guid entity1Id, string entity1Name, Guid entity2Id, string entity2Name)
{
try
{
string relationship1EtityName = string.Format("{0}id", entity1Name);
string relationship2EntityName = string.Format("{0}id", entity2Name);
//This check is added for self-referenced relationships
if (entity1Name.Equals(entity2Name, StringComparison.InvariantCultureIgnoreCase))
{
relationship1EtityName = string.Format("{0}idone", entity1Name);
relationship1EtityName = string.Format("{0}idtwo", entity1Name);
}
QueryExpression query = new QueryExpression(entity1Name)
{
ColumnSet = new ColumnSet(false)
};
LinkEntity link = query.AddLink(relationshipname,string.Format("{0}id", entity1Name), relationship1EtityName);
link.LinkCriteria.AddCondition(relationship1EtityName,ConditionOperator.Equal, new object[] { entity1Id });
link.LinkCriteria.AddCondition(relationship2EntityName,ConditionOperator.Equal, new object[] { entity2Id });
return service.RetrieveMultiple(query).Entities.Count != 0;
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
bool isRelationshipExists = RelationshipExists(service, relationshipentityname, entityid, entityname, entityreferenceId, entityreferencename);
if (!isRelationshipExists)
{
}
{
try
{
string relationship1EtityName = string.Format("{0}id", entity1Name);
string relationship2EntityName = string.Format("{0}id", entity2Name);
//This check is added for self-referenced relationships
if (entity1Name.Equals(entity2Name, StringComparison.InvariantCultureIgnoreCase))
{
relationship1EtityName = string.Format("{0}idone", entity1Name);
relationship1EtityName = string.Format("{0}idtwo", entity1Name);
}
QueryExpression query = new QueryExpression(entity1Name)
{
ColumnSet = new ColumnSet(false)
};
LinkEntity link = query.AddLink(relationshipname,string.Format("{0}id", entity1Name), relationship1EtityName);
link.LinkCriteria.AddCondition(relationship1EtityName,ConditionOperator.Equal, new object[] { entity1Id });
link.LinkCriteria.AddCondition(relationship2EntityName,ConditionOperator.Equal, new object[] { entity2Id });
return service.RetrieveMultiple(query).Entities.Count != 0;
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
bool isRelationshipExists = RelationshipExists(service, relationshipentityname, entityid, entityname, entityreferenceId, entityreferencename);
if (!isRelationshipExists)
{
}
CRM 2011 - Atama İşlemi (Assign Team or User)
Assign işlemi kullanıcıya ya da takıma yapılabilir . Bunun için aşağıdaki metoda hangi kayıt ı kime assign edeceğimiz bilgilerini göndermek yeterli olacaktır.
Target : Atama yapılacak varlık
Assignee : Atama yapılacak kullanıcı ya da takım
public static void AssignTeamorUser(IOrganizationService serviceCRM, string assigneeLogicalName, Guid assigneeGuidId, string targetLogicalName, Guid targetGuidId)
{
try
{
AssignRequest assign = new AssignRequest
{
Assignee = new EntityReference(assigneeLogicalName, assigneeGuidId),
Target = new EntityReference(targetLogicalName, targetGuidId)
};
serviceCRM.Execute(assign);
}
catch (Exception ex)
{
throw ex;
}
}
Target : Atama yapılacak varlık
Assignee : Atama yapılacak kullanıcı ya da takım
public static void AssignTeamorUser(IOrganizationService serviceCRM, string assigneeLogicalName, Guid assigneeGuidId, string targetLogicalName, Guid targetGuidId)
{
try
{
AssignRequest assign = new AssignRequest
{
Assignee = new EntityReference(assigneeLogicalName, assigneeGuidId),
Target = new EntityReference(targetLogicalName, targetGuidId)
};
serviceCRM.Execute(assign);
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 - CRM Arayüzü Dilini Değiştirme (Change User Interface Language)
CRM ana ekranında File butonuna tıklayalım. Gelen seçeneklerden Options a tıklayalım.
Set Personal Options penceresinde Languages tabının altından User Interface Languages kısmından crm i kulanacağımız dili seçelim.Ok butonuna basalım.
Not : Kullanıcı arayüzü dilini seçecegimiz dili ilk önce CRM e yüklememiz gerekir.
Set Personal Options penceresinde Languages tabının altından User Interface Languages kısmından crm i kulanacağımız dili seçelim.Ok butonuna basalım.
Not : Kullanıcı arayüzü dilini seçecegimiz dili ilk önce CRM e yüklememiz gerekir.
CRM 2011 QueryExpression - Fiyat Listesi İçerisindeki Fiyat Listesi Kalemlerini Çekme (Get ProductPriceLevel in PriceLevel)
public static EntityCollection GetProductPriceLevel(IOrganizationService ser, Guid pricelevelid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("productpricelevel", "pricelevelid", pricelevelid, columnset);
EntityCollection ec = RetrieveMultipleQuery(ser, query);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
EntityCollection ec_Products = CrmManagerStatic.GetProductPriceLevel(crmService, priceList.Id, new ColumnSet(new string[] { "productpricelevelid", "productid", "amount" }));
if (ec_Products != null && ec_Products.Entities.Count != 0)
{
}
{
try
{
QueryExpression query = GetQueryExpressionSingle("productpricelevel", "pricelevelid", pricelevelid, columnset);
EntityCollection ec = RetrieveMultipleQuery(ser, query);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
EntityCollection ec_Products = CrmManagerStatic.GetProductPriceLevel(crmService, priceList.Id, new ColumnSet(new string[] { "productpricelevelid", "productid", "amount" }));
if (ec_Products != null && ec_Products.Entities.Count != 0)
{
}
CRM 2011 QueryExpression - Fiyat Listesi Çekme (Get PriceLevel)
public static PriceLevel GetPriceLevel(IOrganizationService ser, Guid pricelevelid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("pricelevel", "pricelevelid", pricelevelid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (PriceLevel)ec.Entities[0];
else
return new PriceLevel();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
PriceLevel priceList = CrmManagerStatic.GetPriceLevel(crmService, _pricelevelid, new ColumnSet("pricelevelid", "transactioncurrencyid"));
;
{
try
{
QueryExpression query = GetQueryExpressionSingle("pricelevel", "pricelevelid", pricelevelid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (PriceLevel)ec.Entities[0];
else
return new PriceLevel();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
PriceLevel priceList = CrmManagerStatic.GetPriceLevel(crmService, _pricelevelid, new ColumnSet("pricelevelid", "transactioncurrencyid"));
;
CRM 2011 QueryExpression - FiyatListesi Kalemi Çekme (Get ProductPriceLevel)
public static ProductPriceLevel GetProductPriceLevel(IOrganizationService ser, Guid productpricelevelid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("productpricelevel", "productpricelevelid", productpricelevelid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (ProductPriceLevel)ec.Entities[0];
else
return new ProductPriceLevel();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
ProductPriceLevel priceListItem = CrmManagerStatic.GetProductPriceLevel(crmService, productPriceLevelId, new ColumnSet("productpricelevelid", "uomid", "amount"));
{
try
{
QueryExpression query = GetQueryExpressionSingle("productpricelevel", "productpricelevelid", productpricelevelid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (ProductPriceLevel)ec.Entities[0];
else
return new ProductPriceLevel();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
ProductPriceLevel priceListItem = CrmManagerStatic.GetProductPriceLevel(crmService, productPriceLevelId, new ColumnSet("productpricelevelid", "uomid", "amount"));
CRM 2011 QueryExpression - Not Çekme (Get Annotation)
public static EntityCollection GetAnnotation(IOrganizationService crmService, Guid activityid, ColumnSet columnset)
{
try
{
QueryExpression query = new QueryExpression
{
EntityName = Annotation.EntityLogicalName,
ColumnSet = columnset,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("objectid",ConditionOperator.Equal,activityid)
}
}
};
return crmService.RetrieveMultiple(query);
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ecNotes = CrmManagerStatic.GetAnnotation(crmService, invoice.Id, new ColumnSet() { AllColumns = true });
{
try
{
QueryExpression query = new QueryExpression
{
EntityName = Annotation.EntityLogicalName,
ColumnSet = columnset,
Criteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("objectid",ConditionOperator.Equal,activityid)
}
}
};
return crmService.RetrieveMultiple(query);
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ecNotes = CrmManagerStatic.GetAnnotation(crmService, invoice.Id, new ColumnSet() { AllColumns = true });
CRM 2011 QueryExpression - Kullanıcı Çekme (Get SystemUser)
public static SystemUser GetSystemUser(IOrganizationService ser, Guid userid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("systemuser", "systemuserid", userid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SystemUser)ec.Entities[0];
else
return new SystemUser();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
SystemUser user= CrmManagerStatic.GetSystemUser(crmService, userid, new ColumnSet("systemuserid", "domainname", "internalemailaddress", "siteid"));
{
try
{
QueryExpression query = GetQueryExpressionSingle("systemuser", "systemuserid", userid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SystemUser)ec.Entities[0];
else
return new SystemUser();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
SystemUser user= CrmManagerStatic.GetSystemUser(crmService, userid, new ColumnSet("systemuserid", "domainname", "internalemailaddress", "siteid"));
CRM 2011 QueryExpresion - Domain Adına Göre Kullanıcı Çekme (Get SystemUser )
public static SystemUser GetSystemUser(IOrganizationService ser, string domainname, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("systemuser", "domainname", domainname, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SystemUser)ec.Entities[0];
else
return new SystemUser();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
{
try
{
QueryExpression query = GetQueryExpressionSingle("systemuser", "domainname", domainname, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SystemUser)ec.Entities[0];
else
return new SystemUser();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
CRM 2011 QueryExpression - Firma Çekme (Get Account)
public static Account GetAccount(IOrganizationService ser, Guid accountid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("account", "accountid", accountid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Account)ec.Entities[0];
else
return new Account();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Account account = CrmManagerStatic.GetAccount(crmService, accountId, new ColumnSet(new string[] { "accountid", "name" }));
if (account != null && account.Id != Guid.Empty)
{
}
{
try
{
QueryExpression query = GetQueryExpressionSingle("account", "accountid", accountid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Account)ec.Entities[0];
else
return new Account();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Account account = CrmManagerStatic.GetAccount(crmService, accountId, new ColumnSet(new string[] { "accountid", "name" }));
if (account != null && account.Id != Guid.Empty)
{
}
CRM 2011 QueryExpression - Firma nın İlgili Kişilerini Çekme (Get Contacts in Account)
public static EntityCollection GetContactsInAccount(IOrganizationService ser, Guid accountid, ColumnSet columnset)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "contact",
ColumnSet = columnset,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("statecode",ConditionOperator.Equal,(int)ContactState.Active)
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="contact",
LinkFromAttributeName="parentcustomerid",
LinkToEntityName = "account",
LinkToAttributeName = "accountid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("accountid",ConditionOperator.Equal,accountid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ecContacts = CrmManagerStatic.GetContactsInAccount(crmServiceAdmin, item, new ColumnSet(new string[] { "contactid", "parentcustomerid" }));
if (ecContacts != null && ecContacts.Entities.Count != 0)
{
foreach (var itemContact in ecContacts.Entities)
{
}
}
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "contact",
ColumnSet = columnset,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("statecode",ConditionOperator.Equal,(int)ContactState.Active)
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="contact",
LinkFromAttributeName="parentcustomerid",
LinkToEntityName = "account",
LinkToAttributeName = "accountid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("accountid",ConditionOperator.Equal,accountid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
Metot Kullanımı
EntityCollection ecContacts = CrmManagerStatic.GetContactsInAccount(crmServiceAdmin, item, new ColumnSet(new string[] { "contactid", "parentcustomerid" }));
if (ecContacts != null && ecContacts.Entities.Count != 0)
{
foreach (var itemContact in ecContacts.Entities)
{
}
}
CRM 2011 QueryExpression - Mektup Çekme (Get Letter)
public static Letter GetLetter(IOrganizationService ser, Guid letterid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("letter", "activityid", letterid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Letter)ec.Entities[0];
else
return new Letter();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Letter letter = CrmManagerStatic.GetLetter(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
{
try
{
QueryExpression query = GetQueryExpressionSingle("letter", "activityid", letterid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Letter)ec.Entities[0];
else
return new Letter();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Letter letter = CrmManagerStatic.GetLetter(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
CRM 2011 QueryExpression - Servis Aktivitesi Çekme (Get ServiceAppointment)
public static ServiceAppointment GetServiceAppointment(IOrganizationService ser, Guid serviceappointmentid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("serviceappointment", "activityid", serviceappointmentid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (ServiceAppointment)ec.Entities[0];
else
return new ServiceAppointment();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
ServiceAppointment serviceAppointment = CrmManagerStatic.GetServiceAppointment(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
{
try
{
QueryExpression query = GetQueryExpressionSingle("serviceappointment", "activityid", serviceappointmentid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (ServiceAppointment)ec.Entities[0];
else
return new ServiceAppointment();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
ServiceAppointment serviceAppointment = CrmManagerStatic.GetServiceAppointment(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
CRM 2011 QueryExpression - Randevu Çekme (Get Appointment)
public static Appointment GetAppointment(IOrganizationService ser, Guid appointmentid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("appointment", "activityid", appointmentid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Appointment)ec.Entities[0];
else
return new Appointment();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Appointment appointment = CrmManagerStatic.GetAppointment(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
{
try
{
QueryExpression query = GetQueryExpressionSingle("appointment", "activityid", appointmentid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Appointment)ec.Entities[0];
else
return new Appointment();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Appointment appointment = CrmManagerStatic.GetAppointment(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
CRM 2011 QueryExpression - Telefon Görüşmesi Çekme (Get PhoneCall)
public static PhoneCall GetPhoneCall(IOrganizationService ser, Guid phonecallid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("phonecall", "activityid", phonecallid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (PhoneCall)ec.Entities[0];
else
return new PhoneCall();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
PhoneCall phoneCall = CrmManagerStatic.GetPhoneCall(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "from", "to", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
{
try
{
QueryExpression query = GetQueryExpressionSingle("phonecall", "activityid", phonecallid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (PhoneCall)ec.Entities[0];
else
return new PhoneCall();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
PhoneCall phoneCall = CrmManagerStatic.GetPhoneCall(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "from", "to", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
CRM 2011 QueryExpression - Fax Çekme (Get Fax)
public static Fax GetFax(IOrganizationService ser, Guid faxid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("fax", "activityid", faxid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Fax)ec.Entities[0];
else
return new Fax();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Fax fax = CrmManagerStatic.GetFax(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "from", "to", "actualdurationminutes", "statecode", "statuscode" }));
i
{
try
{
QueryExpression query = GetQueryExpressionSingle("fax", "activityid", faxid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Fax)ec.Entities[0];
else
return new Fax();
}
catch (Exception ex)
{
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Fax fax = CrmManagerStatic.GetFax(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "from", "to", "actualdurationminutes", "statecode", "statuscode" }));
i
CRM 2011 QueryExpression - Görev Çekme (Get Task)
public static Task GetTask(IOrganizationService ser, Guid taskid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("task", "activityid", taskid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Task)ec.Entities[0];
else
return new Task();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Task GetTask(IOrganizationService ser, Guid taskid, ColumnSet columnset)" + Environment.NewLine +
"TaskId :" + CommonFunction.ToString(taskid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Task task = CrmManagerStatic.GetTask(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
{
try
{
QueryExpression query = GetQueryExpressionSingle("task", "activityid", taskid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Task)ec.Entities[0];
else
return new Task();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Task GetTask(IOrganizationService ser, Guid taskid, ColumnSet columnset)" + Environment.NewLine +
"TaskId :" + CommonFunction.ToString(taskid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Task task = CrmManagerStatic.GetTask(crmService, item, new ColumnSet(new string[] { "activityid", "regardingobjectid", "ownerid", "activitytypecode", "actualdurationminutes", "statecode", "statuscode" }));
CRM 2011 QueryExpression - Sipariş İçerisindeki Faturaları Çekme (Get Invoice in SalesOrder)
public static EntityCollection GetInvoiceInSalesOrder(IOrganizationService ser, Guid salesorderid, ColumnSet columnset)
{
try
{
QueryExpression query = new QueryExpression()
{
EntityName = "invoice",
ColumnSet = columnset,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("statecode",ConditionOperator.Equal,(int)InvoiceState.Active)
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="invoice",
LinkFromAttributeName="salesorderid",
LinkToEntityName = "salesorder",
LinkToAttributeName = "salesorderid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("salesorderid",ConditionOperator.Equal,salesorderid)
}
}
}
}
};
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
{
try
{
QueryExpression query = new QueryExpression()
{
EntityName = "invoice",
ColumnSet = columnset,
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("statecode",ConditionOperator.Equal,(int)InvoiceState.Active)
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="invoice",
LinkFromAttributeName="salesorderid",
LinkToEntityName = "salesorder",
LinkToAttributeName = "salesorderid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("salesorderid",ConditionOperator.Equal,salesorderid)
}
}
}
}
};
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 QueryExpression - Fatura Ürünlerini Çekme (Get Invoice Details in Invoice)
public static EntityCollection GetInvoiceDetailInInvoice(IOrganizationService ser, Guid invoiceid, ColumnSet columnset)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "invoicedetail",
ColumnSet = columnset,
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="invoicedetail",
LinkFromAttributeName="invoiceid",
LinkToEntityName = "invoice",
LinkToAttributeName = "invoiceid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("invoiceid",ConditionOperator.Equal,invoiceid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "invoicedetail",
ColumnSet = columnset,
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="invoicedetail",
LinkFromAttributeName="invoiceid",
LinkToEntityName = "invoice",
LinkToAttributeName = "invoiceid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("invoiceid",ConditionOperator.Equal,invoiceid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 QueryExpression - Fatura Çekme (Get Invoice)
{
try
{
QueryExpression query = GetQueryExpressionSingle("invoice", "invoiceid", invoiceid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Invoice)ec.Entities[0];
else
return new Invoice();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Invoice GetInvoice (IOrganizationService ser, Guid invoiceid, ColumnSet columnset)" + Environment.NewLine +
"InvoiceId :" + CommonFunction.ToString(invoiceid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Invoice fatura = CrmManagerStatic.GetInvoice(crmService, invoiceid, new ColumnSet("invoiceid", "pricelevelid"));
try
{
QueryExpression query = GetQueryExpressionSingle("invoice", "invoiceid", invoiceid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Invoice)ec.Entities[0];
else
return new Invoice();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Invoice GetInvoice (IOrganizationService ser, Guid invoiceid, ColumnSet columnset)" + Environment.NewLine +
"InvoiceId :" + CommonFunction.ToString(invoiceid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
Invoice fatura = CrmManagerStatic.GetInvoice(crmService, invoiceid, new ColumnSet("invoiceid", "pricelevelid"));
CRM 2011 QueryExpression - Sipariş Id ye Göre Siparis Ürünlerini Çekme (Get OrderDetails in Order)
public static EntityCollection OrderDetailInOrder(IOrganizationService ser, Guid orderid, ColumnSet columnset)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "salesorderdetail",
ColumnSet = columnset,
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="salesorderdetail",
LinkFromAttributeName="salesorderid",
LinkToEntityName = "salesorder",
LinkToAttributeName = "salesorderid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("salesorderid",ConditionOperator.Equal,orderid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "salesorderdetail",
ColumnSet = columnset,
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="salesorderdetail",
LinkFromAttributeName="salesorderid",
LinkToEntityName = "salesorder",
LinkToAttributeName = "salesorderid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("salesorderid",ConditionOperator.Equal,orderid)
}
}
}
}
};
EntityCollection ec = null;
ec = ser.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count != 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
throw ex;
}
}
CRM 2011 QueryExpresison - Sipariş Ürünü Çekme (Get OrderDetail)
public static SalesOrderDetail GetOrderDetail(IOrganizationService ser, Guid orderdetailid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("salesorderdetail", "salesorderdetailid", orderdetailid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SalesOrderDetail)ec.Entities[0];
else
return new SalesOrderDetail();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static SalesOrderDetail GetQuoteDetail(IOrganizationService ser, Guid orderdetailid, ColumnSet columnset)" + Environment.NewLine +
"SalesOrderDetailId :" + CommonFunction.ToString(orderdetailid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
SalesOrderDetail orderDetail = CrmManagerStatic.GetOrderDetail(crmService, orderDetailId, new ColumnSet("manualdiscountamount", "salesorderdetailid", "priceperunit", "quantity", "ite_isinvoice", "salesrepid", "ite_newdiscountpercent"));
{
try
{
QueryExpression query = GetQueryExpressionSingle("salesorderdetail", "salesorderdetailid", orderdetailid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SalesOrderDetail)ec.Entities[0];
else
return new SalesOrderDetail();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static SalesOrderDetail GetQuoteDetail(IOrganizationService ser, Guid orderdetailid, ColumnSet columnset)" + Environment.NewLine +
"SalesOrderDetailId :" + CommonFunction.ToString(orderdetailid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
SalesOrderDetail orderDetail = CrmManagerStatic.GetOrderDetail(crmService, orderDetailId, new ColumnSet("manualdiscountamount", "salesorderdetailid", "priceperunit", "quantity", "ite_isinvoice", "salesrepid", "ite_newdiscountpercent"));
CRM 2011 QueryExpression - Sipariş Çekme (Get Order)
public static SalesOrder GetOrder(IOrganizationService ser, Guid orderid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("salesorder", "salesorderid", orderid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SalesOrder)ec.Entities[0];
else
return new SalesOrder();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static SalesOrder GetOrder(IOrganizationService ser, Guid orderid, ColumnSet columnset)" + Environment.NewLine +
"SalesOrderId :" + CommonFunction.ToString(orderid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
string[] columns = new string[] { "salesorderid", "ite_ps1paymentterm1", "ite_ps1percentage1","ite_ps1amount1",
"ite_ps2paymentterm1","ite_ps2percentage1","ite_ps2amount1",
"ite_ps2paymentterm2","ite_ps2percentage2","ite_ps2amount2",
"ite_ps3paymentterm1","ite_ps3percentage1","ite_ps3amount1",
"ite_ps3paymenterm2","ite_ps3percentage2","ite_ps3amount2",
"ite_ps3paymentterm3","ite_ps3percentage3","ite_ps3amount3",
"ite_paymentschedule", "ite_project","transactioncurrencyid" };
SalesOrder order = CrmManagerStatic.GetOrder(crmService, salesorderid, new ColumnSet(columns));
{
try
{
QueryExpression query = GetQueryExpressionSingle("salesorder", "salesorderid", orderid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (SalesOrder)ec.Entities[0];
else
return new SalesOrder();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static SalesOrder GetOrder(IOrganizationService ser, Guid orderid, ColumnSet columnset)" + Environment.NewLine +
"SalesOrderId :" + CommonFunction.ToString(orderid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Metot Kullanımı
string[] columns = new string[] { "salesorderid", "ite_ps1paymentterm1", "ite_ps1percentage1","ite_ps1amount1",
"ite_ps2paymentterm1","ite_ps2percentage1","ite_ps2amount1",
"ite_ps2paymentterm2","ite_ps2percentage2","ite_ps2amount2",
"ite_ps3paymentterm1","ite_ps3percentage1","ite_ps3amount1",
"ite_ps3paymenterm2","ite_ps3percentage2","ite_ps3amount2",
"ite_ps3paymentterm3","ite_ps3percentage3","ite_ps3amount3",
"ite_paymentschedule", "ite_project","transactioncurrencyid" };
SalesOrder order = CrmManagerStatic.GetOrder(crmService, salesorderid, new ColumnSet(columns));
CRM 2011 QueryExpresison - Guid si Bilinen Teklifi Çekme (Get Quote)
public static Quote GetQuote(IOrganizationService ser, Guid quoteid, ColumnSet columnset)
{
try
{
QueryExpression query = GetQueryExpressionSingle("quote", "quoteid", quoteid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Quote)ec.Entities[0];
else
return new Quote();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Quote GetQuote(IOrganizationService ser, Guid quoteid, ColumnSet columnset)" + Environment.NewLine +
"QuoteId :" + CommonFunction.ToString(quoteid));
throw ex;
}
}
GetQueryExpressionSingle metodu
{
try
{
QueryExpression query = GetQueryExpressionSingle("quote", "quoteid", quoteid, columnset);
EntityCollection ec = ser.RetrieveMultiple(query);
if (ec != null && ec.Entities.Count == 1)
return (Quote)ec.Entities[0];
else
return new Quote();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static Quote GetQuote(IOrganizationService ser, Guid quoteid, ColumnSet columnset)" + Environment.NewLine +
"QuoteId :" + CommonFunction.ToString(quoteid));
throw ex;
}
}
GetQueryExpressionSingle metodu
Kaydol:
Kayıtlar (Atom)