How to create web service for update crm record RRS feed

  • Question

  • Hi,

    I have an entity "new_sms" and its attribute is "new_status" I want to create a web service which update status ="send" where status =="pending".this web service automatically run and update records on background

    Wednesday, April 23, 2014 11:35 AM


  • Hi,

    you can create a standard webservice with a new route called UpdateRecord for example. Inside update record you can insert this code:

    Uri organizationUri = new Uri("http://localhost/Organization/XRMServices/2011/Organization.svc");
                    Uri homeRealmUri = null;
                    ClientCredentials credentials = new ClientCredentials();
                    credentials.Windows.ClientCredential = new NetworkCredential("user", "password");

                    using (OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(

                        IOrganizationService service = (IOrganizationService)_serviceProxy;

                        QueryExpression query = new QueryExpression();
                        query.EntityName = "new_sms";
                        query.ColumnSet = new ColumnSet(true);
                        //query.Criteria = new FilterExpression();
                        //query.Criteria.FilterOperator = LogicalOperator.And;
                        //query.Criteria.Conditions.Add(new ConditionExpression("new_status", ConditionOperator.Equal, "pending"));

                        EntityCollection entities = _serviceProxy.RetrieveMultiple(query);
                        foreach(Entity et in entities)




                    // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
                catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
                    // You can handle an exception here or pass it back to the calling method.
                catch (Exception ex)
                    throw ex;

    Alessandro Graps

    Wednesday, April 23, 2014 1:48 PM