I have a Silverlight application that needs to get the label of an OptionSetValue attribute from the Activity entity. The attribute logical name is activitytypecode, and I have the following extension method to retrieve an attribute metadata:
public static void RetrieveAttribute(this IOrganizationService service,
string entityLogicalName, string entityAttributeName,
Action<OrganizationResponse> callback)
{
var retrieveAttributeRequest = new OrganizationRequest()
{
RequestName = "RetrieveAttribute",
};
retrieveAttributeRequest["EntityLogicalName"] = entityLogicalName;
retrieveAttributeRequest["RetrieveAsIfPublished "] = false;
retrieveAttributeRequest["LogicalName"] = entityAttributeName;
service.BeginExecute(retrieveAttributeRequest,
result =>
{
if (result.IsCompleted)
{
var response = service.EndExecute(result);
callback(response);
}
}, null);
}
And I use it as follows on my SoapCtx that has already been initialized:
SoapCtx.RetrieveAttribute("activitypointer", "activitytypecode",
orgResponse =>
{
if (orgResponse != null)
{
// examine orgResponse
}
});
I am able to debug the procedure but it fails on the line var response = service.EndExecute(result); in my extension method. I get the following Exception message:
The remote server returned an error: NotFound.
Here’s the StackTrace if you will find it useful:
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
I appreciate any help or guidance, thanks!
Aside from the anonymous method the following worked for me. Please note MetadataId