2017-10-29 11 views
0

나는 계정 ID를 가지고 있으며 이메일 목록을 만들 계정의 연락처 모음을 얻고 싶습니다.계정의 모든 연락처를 가져 와서 MS Dynamics CRM에서 전자 메일 목록을 작성하는 방법은 무엇입니까?


//build up Email 
    private Email BuildEmail(ActivityParty allcontacts){.... build my emailhere} 

    private List<Entity> GetAllContactsFromAccountId(Guid accountId, List<Entity> toList) 
    {   

     //how can I get all the contacts here 
     foreach (Entity contact in Account.Contact.Entities)//???? 
     { 
      Entity activityParty = new Entity("activityparty"); 
      activityParty["partyid"] = new EntityReference("??", e.Id); 

      if (toList.Any(t => t.GetAttributeValue<EntityReference>("partyid").Id == e.Id)) continue; 

      toList.Add(activityParty); 
     } 

     return toList; 
    } 

답변

0

당신은 연락처 개체의 계정 키 "parentcustomerid"를 찾을 수 있습니다. 아래와 같이 계좌 이체로 연락하실 수 있습니다.

private EntityCollection getContactByAccountId(IOrganizationService service, Guid accountId) 
    { 
     QueryExpression query = new QueryExpression("contact"); 
     query.ColumnSet = new ColumnSet(new string[] { "contactid", "fullname" }); 
     query.Criteria.AddCondition(new ConditionExpression("parentcustomerid", ConditionOperator.Equal, accountId)) 
     return service.RetrieveMultiple(query); 
    } 
+0

답장을 보내 주셔서 감사합니다.하지만 오류가 발생합니다. 예 : 때,이 사용자 지정 워크 플로에서 entitycollection 반환합니다 TargetOutput ref ... ("연락처") 가져 오기 및 오류'entitycollection'을'entityreference'로 변환 할 수 없습니다. – transformer

+0

당신은 EntityCollection 형식의 출력 매개 변수를 사용할 수 있다고 생각합니다. [Output ("Contacts")] [ReferenceTarget ("contact")] 공개 OutArgument 연락처 {get; 세트; }. 그리고 분명히 entityCollection 객체를 entityReference로 설정할 수 없습니다. –