locked
Custom attributes cannot be found using the RetrieveAttributeRequest RRS feed

  • Question

  • I'm trying to retreive the picklist items in a custom attribute of a contact entity.  Here is my code:

                RetrieveAttributeRequest request = new RetrieveAttributeRequest();
                request.EntityLogicalName = "contact";
                request.LogicalName = "cfpdepartment";
                request.RetrieveAsIfPublished = true;
    
                MetadataService mdService = GetMetadataService("CRMDEV");
               
                RetrieveAttributeResponse response = (RetrieveAttributeResponse)mdService.Execute(request);


    The above code works when the request.LogicalName is set to a standard attribute such as "gendercode".  Yet when I query a custom attribute ("cfpdepartment" in this example) I get the following error on the last line of the above code:
           0x80040217 Could not find an attribute with specified name: cfpdepartment

    I've used the Entity Navigator to verify that the cfpdepartment attribute exists and is a picklist as shown below:
    cfpdepartment
    picklist         yes yes yes     yes yes yes

    Any ideas why the above code only works on standard attributes and not custom attributes?
    Wednesday, June 3, 2009 4:39 PM

Answers

  • The problem you might be running into is the LogicalName is case sensitive.  I used the RetrieveEntityRequest and iterated through the attributes, and all custom attributes from CRM 1.2 had the prefix capitalized.

    Try CFPdepartment instead of cfpdepartment.

    Wednesday, June 3, 2009 6:05 PM

All replies

  • Be sure to "publish" the contact after having added the attributes.

    And typically the custom attribute will be named "new_something" unles you've changed the prefix to something else.


    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
    Wednesday, June 3, 2009 5:25 PM
    Moderator
  • Hi,

    i think, your custom attribut sound like cfp_department, not cfpdepartmen, right? Then you have to use cfp_department.


    Viele Grüße

    Michael Sulz
    axcentro GmbH
    • Proposed as answer by Michael Sulz Wednesday, June 3, 2009 5:25 PM
    Wednesday, June 3, 2009 5:25 PM
  • I have tested your code and i am able to recreate the behavior.  When I retrieve attributes created after our CRM was upgrade to 3.0, the code works as expected, but when I attempt to retrieve attributes added to CRM 1.2, the code errors as noted above.
    Wednesday, June 3, 2009 5:58 PM
  • The problem you might be running into is the LogicalName is case sensitive.  I used the RetrieveEntityRequest and iterated through the attributes, and all custom attributes from CRM 1.2 had the prefix capitalized.

    Try CFPdepartment instead of cfpdepartment.

    Wednesday, June 3, 2009 6:05 PM
  • Richard, you are correct, this attribute has been around for quite some time (since 1.2).

    Using the Entity Navigator I verified that there indeed is a field called cfpdepartment.  I figured this would be the best way to verify that a custom attribute exists.  Wrong!

    It turns out that the Entity Navigator lists all attributes in lowercase even if they aren't truely that case.  So in my example, even though the Entity Navigator lists the attribute as cfpdepartment it actually is CFPDepartment.  Since the Metadata Service is case sensitive it couldn't find cfpdepartment.

    Using the proper case works.

    Thanks to all who got me investigating the attribute name further.

    Wednesday, June 3, 2009 6:08 PM