none
请教partlist 问题?? RRS feed

  • 问题

  • partylist    我想实现上面部分multi 方式  但下半部分为single方式
    即:contact1,contact2  两种联系人仅可选其一   请问各位该如何实现??? 

    2009年12月16日 8:00

答案

  • Google Blogs 可能不能在中国看。


    Create Activities using the Dynamic Entity Way

    I haven't touch CRM SDK for a while since I am working on another project not directly related to CRM. One of my old client required us to populate CRM with some more training data so they can use it for their training. So I have to modify the training processor that my teammates wrote to add activities to CRM. It appears to me that everything in the training processor have used Dynamic Entity for create, update, and delete.

    To create an activities using dynamic entity is pretty straight forward, however I got stuck when I have to deal with the sender and recipient fields on a phone call, email, appointment and fax activity. Sender and Recipient field are ActivityParty type, I have done some research online and I was not able to find a way to associate the two fields to an activity using the dynamic approach. After going through the SDK and I was able to figure it out. I would like to share it since you might have to do the same in your next project.

    Method 1: Not using Dynamic Entity

    activityparty actParty = new activityparty();
    actParty.partyid = new Lookup();
    actParty.partyid.Value = new Guid("ENTER CONTACT GUID");
    actParty.partyid.type = "contact";

    activityparty actParty2 = new activityparty();
    actParty2.partyid = new Lookup();
    actParty2.partyid.Value = new Guid("ENTER USER GUID");
    actParty2.partyid.type = "systemuser";

    phonecall call = new phonecall();
    call.from = new activityparty[] { actParty };
    call.to = new activityparty[] { actParty2 };
    call.description = "Test";

    crmService.Create(call);



    Method 2: Using Dynamic Entity




    Property subject = new StringProperty();
    ((StringProperty)subject).Name = "subject";
    ((StringProperty)subject).Value = "Test";

    Property description = new StringProperty();
    ((StringProperty)description).Name = "description";
    ((StringProperty)description).Value = "Test";

    // Create From:
    Property party1 = new LookupProperty();
    ((LookupProperty)party1).Name = "partyid";
    ((LookupProperty)party1).Value = new Lookup();
    ((LookupProperty)party1).Value.type = "contact";
    ((LookupProperty)party1).Value.Value = new Guid("ENTER CONTACT GUID");

    DynamicEntity actParty1 = new DynamicEntity();
    actParty1.Name = "activityparty";
    actParty1.Properties = new Property[] { party1 };

    DynamicEntityArrayProperty from = new DynamicEntityArrayProperty();
    ((DynamicEntityArrayProperty)from).Name = "from";
    ((DynamicEntityArrayProperty)from).Value = new DynamicEntity[] { actParty1 };

    // Create To:
    Property party2 = new LookupProperty();
    ((LookupProperty)party2).Name = "partyid";
    ((LookupProperty)party2).Value = new Lookup();
    ((LookupProperty)party2).Value.type = "systemuser";
    ((LookupProperty)party2).Value.Value = new Guid("ENTER USER GUID");

    DynamicEntity actParty2 = new DynamicEntity();
    actParty2.Name = "activityparty";
    actParty2.Properties = new Property[] { party2 };

    DynamicEntityArrayProperty to = new DynamicEntityArrayProperty();
    ((DynamicEntityArrayProperty)to).Name = "to";
    ((DynamicEntityArrayProperty)to).Value = new DynamicEntity[] { actParty2 };

     

    // Create Phone Call Activity:
    DynamicEntity activity = new DynamicEntity();
    activity.Name = EntityName.phonecall.ToString();
    activity.Properties = new Property[]{subject, description, from, to};

    TargetCreateDynamic target = new TargetCreateDynamic();
    target.Entity = activity;

    CreateRequest request = new CreateRequest();
    request.Target = target;

    CreateResponse response = (CreateResponse)crmService.Execute(request);




    That's it! Hope this will help you in your next project! :)


    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    2009年12月17日 14:07
    版主

全部回复

  • 问题补充,partylist  多选时  刀哥的四级联动例子 就没有作用了!!~~~  搜索栏中可以得到id  但点击搜索就是不能查找信息!!
    1.是不是单选时用search参数  多选时就不起作用了??
    2.我把查询条件改为name 显示一串数字  怎么回事??“1260954143312”??
    3.顶楼的问题??
    哪位高手帮一一解释下??
    2009年12月16日 9:14
  • Partylist是CRM的一个实体, 可以当CRM实体对待。

    我这个例子使用到 Partylist, 希望帮到你的忙吧。




    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    2009年12月16日 13:54
    版主
  • 链接地址无法打开。。。

    2009年12月17日 7:41
  • Google Blogs 可能不能在中国看。


    Create Activities using the Dynamic Entity Way

    I haven't touch CRM SDK for a while since I am working on another project not directly related to CRM. One of my old client required us to populate CRM with some more training data so they can use it for their training. So I have to modify the training processor that my teammates wrote to add activities to CRM. It appears to me that everything in the training processor have used Dynamic Entity for create, update, and delete.

    To create an activities using dynamic entity is pretty straight forward, however I got stuck when I have to deal with the sender and recipient fields on a phone call, email, appointment and fax activity. Sender and Recipient field are ActivityParty type, I have done some research online and I was not able to find a way to associate the two fields to an activity using the dynamic approach. After going through the SDK and I was able to figure it out. I would like to share it since you might have to do the same in your next project.

    Method 1: Not using Dynamic Entity

    activityparty actParty = new activityparty();
    actParty.partyid = new Lookup();
    actParty.partyid.Value = new Guid("ENTER CONTACT GUID");
    actParty.partyid.type = "contact";

    activityparty actParty2 = new activityparty();
    actParty2.partyid = new Lookup();
    actParty2.partyid.Value = new Guid("ENTER USER GUID");
    actParty2.partyid.type = "systemuser";

    phonecall call = new phonecall();
    call.from = new activityparty[] { actParty };
    call.to = new activityparty[] { actParty2 };
    call.description = "Test";

    crmService.Create(call);



    Method 2: Using Dynamic Entity




    Property subject = new StringProperty();
    ((StringProperty)subject).Name = "subject";
    ((StringProperty)subject).Value = "Test";

    Property description = new StringProperty();
    ((StringProperty)description).Name = "description";
    ((StringProperty)description).Value = "Test";

    // Create From:
    Property party1 = new LookupProperty();
    ((LookupProperty)party1).Name = "partyid";
    ((LookupProperty)party1).Value = new Lookup();
    ((LookupProperty)party1).Value.type = "contact";
    ((LookupProperty)party1).Value.Value = new Guid("ENTER CONTACT GUID");

    DynamicEntity actParty1 = new DynamicEntity();
    actParty1.Name = "activityparty";
    actParty1.Properties = new Property[] { party1 };

    DynamicEntityArrayProperty from = new DynamicEntityArrayProperty();
    ((DynamicEntityArrayProperty)from).Name = "from";
    ((DynamicEntityArrayProperty)from).Value = new DynamicEntity[] { actParty1 };

    // Create To:
    Property party2 = new LookupProperty();
    ((LookupProperty)party2).Name = "partyid";
    ((LookupProperty)party2).Value = new Lookup();
    ((LookupProperty)party2).Value.type = "systemuser";
    ((LookupProperty)party2).Value.Value = new Guid("ENTER USER GUID");

    DynamicEntity actParty2 = new DynamicEntity();
    actParty2.Name = "activityparty";
    actParty2.Properties = new Property[] { party2 };

    DynamicEntityArrayProperty to = new DynamicEntityArrayProperty();
    ((DynamicEntityArrayProperty)to).Name = "to";
    ((DynamicEntityArrayProperty)to).Value = new DynamicEntity[] { actParty2 };

     

    // Create Phone Call Activity:
    DynamicEntity activity = new DynamicEntity();
    activity.Name = EntityName.phonecall.ToString();
    activity.Properties = new Property[]{subject, description, from, to};

    TargetCreateDynamic target = new TargetCreateDynamic();
    target.Entity = activity;

    CreateRequest request = new CreateRequest();
    request.Target = target;

    CreateResponse response = (CreateResponse)crmService.Execute(request);




    That's it! Hope this will help you in your next project! :)


    Darren Liu | 刘嘉鸿 | MS CRM MVP | English Blog: http://msdynamicscrm-e.blogspot.com | Chinese Blog: http://liudarren.spaces.live.com
    2009年12月17日 14:07
    版主