locked
Get Custom Attribute in Entity Instance RRS feed

  • Question

  • hi,

     

    I'm using SSIS packages to integrate between and external System and CRM. I have created a lot of custom attribute on the level of the Contact and Account Entities, while trying to map the fields between the external System and CRM, i have created a new instance of the Contact Object. when i try to use this instance, i am getting all the predefined attributes already created on installation but i'm not able to access the custom attributes i have created in order to map them.

     

    For example, i have created an attribute and named it " Customer Number" the Name is "new_customernumber"

     

    I created :

    Contact con = new Contact()

     

    Contact.... (i'm not getting the "new_customernumber"

     

    can anyone help me in this ?


    GKSPLB
    Monday, April 18, 2011 7:37 AM

Answers

  • Hello,

     

    I worked finally after few tests and this is the solution :

     

    Guid myid = new Guid();

    DynamicEntity ContactEntity = new DynamicEntity("contact");

    StringProperty new_CustomerNumber = new StringProperty();
                new_CustomerNumber.Name = "new_cifnumber";
                new_CustomerNumber.Value = "My Value";

    ContactEntity.Properties.Add(new_CustomerNumber );

     

     myid = service.Create(ContactEntity);

     

    Thanks


    GKSPLB
    • Marked as answer by GKSPLB Wednesday, April 20, 2011 1:09 PM
    Wednesday, April 20, 2011 1:09 PM

All replies

  • hi ,

    I believe its for CRM 4.0

    if you are using the SDK DLLs the custom atttributes will not be available for the same youhave two options :

    1. use dynamic entity
    see here for details (http://blogs.infinite-x.net/2008/08/01/working-with-dynamic-entities-in-crm-40/)
    also http://msdn.microsoft.com/en-us/library/cc151183.aspx

    2. use the WSDL in your reference
        download teh WSDL of CRM service from your CRM organization and add them as web reference.
        with this you will be able to get the "new_customernumber" in the manner you are trying to access it.

     

     

     



    vishal swami

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    http://msdynamics4you.blogspot.com
    Monday, April 18, 2011 8:33 AM
  •  

    it's like

     

    DynamicEntity ContactEntity= new DynamicEntity("Contact");
    ContactEntity["new_customernumber"] = <your value>;



    vishal swami

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    http://msdynamics4you.blogspot.com
    Monday, April 18, 2011 8:37 AM
  • Sorry Guys, i tried this solution and it didn't work, it is not generating any error but it seems that i'm not able to catch the attribute field to store my value in it. is there anything missing in this small piece of Code?

     

    thanks


    GKSPLB
    Monday, April 18, 2011 2:36 PM
  • Hello,

     

    The problem was clarifed more and more, i'm missing something here. I have a contact entity, where i'm mapping fields to it from an external system. The predefined attributes are working fine, but when i create a dynamic Entity to be able to access the new customized attributes, i'm not finding the proper way to append the record and add the values of the fields in the dynamic entity ... how can this be done?

     

    thanks


    GKSPLB
    Tuesday, April 19, 2011 6:39 AM
  • Hello,

     

    I worked finally after few tests and this is the solution :

     

    Guid myid = new Guid();

    DynamicEntity ContactEntity = new DynamicEntity("contact");

    StringProperty new_CustomerNumber = new StringProperty();
                new_CustomerNumber.Name = "new_cifnumber";
                new_CustomerNumber.Value = "My Value";

    ContactEntity.Properties.Add(new_CustomerNumber );

     

     myid = service.Create(ContactEntity);

     

    Thanks


    GKSPLB
    • Marked as answer by GKSPLB Wednesday, April 20, 2011 1:09 PM
    Wednesday, April 20, 2011 1:09 PM