locked
About given code RRS feed

  • Question

  • Given code is generating error for

    1)SilverlightUtility.GetSoapService(); mehtod       and 

    2)its not creating indexing to request object of OrganizationRequest  class

     OrganizationRequest request = new OrganizationRequest();

    request["EntityLogicalName"] = entityName;
                request["LogicalName"] = attributeName;
                request["MetadataId"] = Guid.Empty;
                request["RetrieveAsIfPublished"] = true;     

    *What is solution for above errors??????????? please guide me..i m new to CRM2011

    Friday, June 1, 2012 12:19 PM

All replies

  • problem 1) 

    This will work only if your application is running inside an crm context, as a crm web resource, you cannot run that code at the local machine. If the exception still persists, you are probably trying to do that from an non UI thread. In that case just write:

    Deployment.Current.Dispatcher.BeginInvoke(() => { SilverlightUtility.GetSoapService(); // do something with service }); 

    If an error is a compile time error, then you should follow this link: http://msdn.microsoft.com/en-us/library/gg594452.aspx

    problem 2)

    I never used organizationrequest this way. I reccommend you to use service.BeginRetrieve or service.BeginUpdate.

    If you want to use service.BeginExecute() Here is an example of how to retrieve all contacts using QueryExpression and OrganizationRequest:

     
    QueryExpression query = new QueryExpression()
                    {
                        EntityName = "contact",
                        ColumnSet = new ColumnSet()
                        {
                            AllColumns = true;
                        }
                        
    
                    OrganizationRequest request = new OrganizationRequest() { RequestName = "RetrieveMultiple" };
                    request["Query"] = query;
                    
                    IOrganizationService service = SilverlightUtility.GetSoapService();
    
                    service.BeginExecute(request, callBack, service);
    The callback function should manage the retrieve operation event.

    Friday, June 1, 2012 1:33 PM