Search code examples
dynamics-crmdynamics-crm-4dynamics-crm-2013

Update Message (CrmService) Dynamics 4.0


I want to update the fields like "cs_hv_additionnalparticularities", "cs_hv_smscope" and so on, but the function srv.Update(de);updates all the form records, I mean it triggers a workflow that I don't want it to happen. here is my code:

 // Retrieve the DynamicEntity that goes with target
        RetrieveRequest retrieve = new RetrieveRequest();
        retrieve.Target = target;
        retrieve.ColumnSet = new AllColumns();
        retrieve.ReturnDynamicEntities = true;
        // Create a response reference and execute the retrieve request.
        RetrieveResponse response1 = (RetrieveResponse)srv.Execute(retrieve);
        DynamicEntity de = (DynamicEntity)response1.BusinessEntity;


            if (opp.Properties.Contains("cs_hv_additionnalparticularities"))
                de["cs_hv_additionnalparticularities"] = opp["cs_hv_additionnalparticularities"];
            if (opp.Properties.Contains("cs_hv_smscope"))
                de["cs_hv_smscope"] = opp["cs_hv_smscope"];
            if (opp.Properties.Contains("cs_hv_ugscope"))
                de["cs_hv_ugscope"] = opp["cs_hv_ugscope"];
            if (opp.Properties.Contains("cs_hv_acdc"))
                de["cs_hv_acdc"] = opp["cs_hv_acdc"];
            if (opp.Properties.Contains("cs_hv_smmv"))
                de["cs_hv_smmv"] = opp["cs_hv_smmv"];
            if (opp.Properties.Contains("cs_hv_smhv"))
                de["cs_hv_smhv"] = opp["cs_hv_smhv"];
            if (opp.Properties.Contains("cs_hv_ughv"))
                de["cs_hv_ughv"] = opp["cs_hv_ughv"];
            if (opp.Properties.Contains("cs_hvid"))
                de["cs_hvid"] = opp["cs_hvid"];
            de["cs_generercable"] = new CrmBoolean(true);

           srv.Update(de);

I don't want to use this function srv.Update(de); to update the fields. Can somebody please give me the update function code that can do this work ??


Solution

  • If you don't want to update additional columns, just retrieve the specific columns (property ColumnSet) instead of the new AllColumns().

    You can use only the update the record with the Update method, make sure that your workflow triggers only for the requested fields, and not for additional fields.