Tag: dynamics crm 2011

CRM中的RetrieveRequest和IOrganizationService.Retrieve之间有什么区别?

我是C#的CRM工作流程开发新手。 我需要知道在IOrganizationService RetrieveRequest和Retrieve之间的主要区别是什么。 何时必须使用哪一个? 是否有任何示例来说明如何使用此对象以表演者的方式运行?

获取DateTime CRM 2011

我在使用DateTime时遇到了一些问题:使用Fetch 认为这有点错了…. DateTime scheduledstart = ((DateTime)((AliasedValue)a[“new_startdate”]).Value); tracer.Trace(“DateTime 1 Done”); DateTime enddate = ((DateTime)((AliasedValue)a[“new_enddate”]).Value); tracer.Trace(“DateTime 2 Done”); DateTime scheduledend = ((DateTime)((AliasedValue)a[“new_duedate”]).Value); 然后我添加到新的实体… if (scheduledstart != null) { Activity.Attributes.Add(“scheduledstart”, scheduledstart); } if (enddate != null) { Activity.Attributes.Add(“scheduledend”, enddate); } if (scheduledend != null) { Activity.Attributes.Add(“scheduledend”, scheduledend); } 任何想法如何使用来自fetch的AliasedValue编写DateTime? 或者更好的方法来做到这一点> 谢谢

CRM 2011使用ICodeWriterFilterService生成的代码无法构建

使用http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html上的示例代码,我已对此进行了更改,以便GenerateEntity和GenerateOptionSet具有以下代码: return optionSetMetadata.Name.ToLowerInvariant().StartsWith(“myprefix”); 这将生成类型,包括选项集的一些枚举。 然而,实体中的optionset的实际实现并没有使用它,但我得到以下内容: [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute(“myprefix_fieldname”)] public Microsoft.Xrm.Sdk.OptionSetValue myprefix_FieldName { get { Microsoft.Xrm.Sdk.OptionSetValue optionSet = this.GetAttributeValue(“myprefix_fieldname”); if ((optionSet != null)) { return ((Microsoft.Xrm.Sdk.OptionSetValue)(System.Enum.ToObject(typeof(Microsoft.Xrm.Sdk.OptionSetValue), optionSet.Value))); } else { return null; } } set { this.OnPropertyChanging(“myprefix_FieldName”); if ((value == null)) { this.SetAttributeValue(“myprefix_fieldname”, null); } else { this.SetAttributeValue(“myprefix_fieldname”, new Microsoft.Xrm.Sdk.OptionSetValue(((int)(value)))); } this.OnPropertyChanged(“myprefix_FieldName”); } } 显然,将setSetValue转换为setter中的int不会编译,我假设它应该生成一个类型与生成的枚举匹配的属性,但不是。 我需要做些什么才能纠正这个问题?

在CRM 2011插件中模拟IOrganizationService.Execute的问题

我仍然是嘲笑的新手,我遇到了这段代码的问题: //create the request SendEmailFromTemplateRequest emailUsingTemplateReq = new SendEmailFromTemplateRequest { Target = email, TemplateId = new Guid(“07B94C1D-C85F-492F-B120-F0A743C540E6”), RegardingId = toParty[0].PartyId.Id, RegardingType = toParty[0].PartyId.LogicalName }; //retrieve response SendEmailFromTemplateResponse emailUsingTemplateResponse = (SendEmailFromTemplateResponse)service.Execute(emailUsingTemplateReq); var emailId = emailUsingTemplateResponse.Id; 到目前为止,我没有遇到过模拟IOrganizationService的问题,但我对execute方法做错了。 根据sdk,Execute方法返回一个需要转换为正确响应类的OrganizationResponse对象。 这是我到目前为止所尝试的: var idResults = new ParameterCollection(); idResults.Add(“Id”, Guid.NewGuid()); mockOrganizationService .Setup(os => os.Execute(It.IsAny())) .Returns(new OrganizationResponse { Results = idResults, ResponseName […]

如何从插件中的PartyList获取联系人指南?

我正在创建一个插件,触发自定义活动SMS的创建消息。 这些插件将使用第三方短信服务提供商发送实际的短信。 因此,我需要在SMS活动的“收件人”字段中获取每个联系人的手机号码。 这是一个类型的字段:PartyList。 我目前正在使用以下代码: EntityCollection Recipients; Entity entity = (Entity) context.InputParameters[“Target”]; IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); Content = entity.GetAttributeValue(“subject”); Recipients = entity.GetAttributeValue(“to”); for (int i = 0; i < Recipients.Entities.Count; i++) { Entity ent= Recipients[i]; string number = ent["MobilePhone"].ToString(); } 但这不起作用,我认为ent变量不包含任何属性。 我也尝试使用ActivityParty进行编码,但也没有运气。 我希望你们中的某个人可以帮助我。 谢谢!

MS Dynamics CRM 2011 SDK – 使用后期绑定更新实体记录

有没有人知道如何使用SDK for Dynamics CRM 2011保存对后期绑定实体的更改? 这就是我尝试过的: // retrieve and modify a pet… // (This part works) Guid findId = new Guid(“6CA57D73-30CC-E111-B155-00505630052F”); ColumnSet attributes = new ColumnSet(new string[] { “name”, “foodtype” }); // try to retrieve // (this also works) pet = xrm.Retrieve(“pet”, findId, attributes); if( pet!=null ) { Console.WriteLine( String.Format( “Retrieved pet {0} successfully!”, pet[“name”].ToString() […]

CRM 2011 – 从已连接的实体中检索FormattedValues

我一直在转换我的一些CRM4.0插件来使用CRM2011 SDK。 我刚刚开始使用LINQ for Early-Bound实体,并遇到了一个问题。 我试图在连接的实体中获取OptionSetValue的格式化值。 在查看此MSDN SDK查询示例后 ,我设法检索主要实体的格式化值,但似乎无法将其转换为已连接的实体。 下面的代码是我想要实现的一个示例。 我开始使用SDK示例中的代码。 var query_join8 = (from a in sContext.AccountSet join c in sContext.ContactSet on a.PrimaryContactId.Id equals c.ContactId into gr from c_joined in gr.DefaultIfEmpty() select new { contact_name = c_joined.FullName, account_name = a.Name, account_addresstypecode = a.Address1_AddressTypeCode, account_addresstypename = a.FormattedValues.ContainsKey(“address1_addresstypecode”) ? a.FormattedValues[“address1_addresstypecode”] : null, account_formattedValues = a.FormattedValues, contact_addresstypecode […]

CRM 2011:发生了类型为“System.InvalidOperationException”的未处理exception。 从范围”引用,但它没有定义

我执行此查询时收到以下错误消息。 如果我删除第二个where子句,查询工作正常。 码 (from cl in context.CreateQuery() join a in context.CreateQuery() on cl.CustomerId.Id equals a.AccountId where cl.StateCode.Value == 0 where cl.new_SupportedBy == a.Name select cl).ToList(); 错误 An unhandled exception of type ‘System.InvalidOperationException’ occurred in ConsoleApplication1.exe Additional information: variable ‘h__TransparentIdentifier0’ of type ‘f__AnonymousType0“2[ConsoleApplication1.ContractDetail,ConsoleApplication1.Account]’ referenced from scope ”, but it is not defined UPDATE 尝试将where子句中的值硬编码如下,并将其工作时间。 无法理解是什么问题。 首先尝试: […]

如何获得CRM 2011的所有实体领域?

我试图获取所有实体的字段模式名称,而不查询现有记录。 我什么都不知道。 另外,如何使用QueryExpression获取它,导致它检索包含一些信息的所有字段? Andrii,我正在尝试做这样的事情 var query = new QueryExpression {EntityName = “”, ColumnSet = new ColumnSet(true)}; var retrieve = service.RetrieveMultiple(query);

我需要设置自定义实体的State和StatusCode

我需要使用.Net CRM SDK设置自定义实体的State和StatusCode 。 执行以下代码但在检查实体表单时不更改StatusCode。 private void SetState(Entity entity, int statuscode) { SetStateRequest setState = new SetStateRequest { EntityMoniker = new EntityReference( entity.LogicalName, new Guid(entity.Id.ToString())), State = new OptionSetValue(0), Status = new OptionSetValue(statuscode) }; SetStateResponse myres = (SetStateResponse)svc.Execute(setState); }