How to update the Dynamics 365 workflow triggering update attributes list using C# Code CRM SDK ?

Subject: How to update the Dynamics 365 workflow triggering update attributes list using C# Code CRM SDK ?

Hello Everyone,

I got one strange requirement in my life in Dynamics CRM Project and we would like to share my knowledge with you people.

Requirement: 

Workflow on opportunity and it should trigger on update of fields like customer,total revenue.... but these triggering fields needs to configurable and actual users they don't want to deactivate workflow and activate every time.


Solution: 

we have developed the following piece of code in Plugin

           QueryExpression query = new QueryExpression("workflow");
            query.ColumnSet.AllColumns = true;
            query.Criteria.AddCondition("name", ConditionOperator.Equal, "Test workflow"); // Pass your workflow name
            EntityCollection ec = service.RetrieveMultiple(query);
           

            SetStateRequest deactivateRequest = new SetStateRequest
            {
                EntityMoniker =
                         new EntityReference("workflow", ec.Entities[0].Id),
                State = new OptionSetValue(0),
                Status = new OptionSetValue(1)
            };

            service.Execute(deactivateRequest);
            Entity e = new Entity("workflow");
            e.Attributes["triggeronupdateattributelist"] = "name,customer"; 
               // Pass your triggering fields as comma separated.
            e.Id = ec.Entities[0].Id;
            service.Update(e);

            SetStateRequest activateRequest = new SetStateRequest
            {
                EntityMoniker =
                        new EntityReference("workflow", ec.Entities[0].Id),
                State = new OptionSetValue(1),
                Status = new OptionSetValue(2),


            };
            service.Execute(activateRequest);



Previous Links:

CRMOnce: Dynamics 365 CRM Training Course Content - Hyderabad,Chennai,Banglore,Pune


4 comments:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.

    ReplyDelete
  2. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.






    mobile phone repair in Novi
    iphone repair in Novi
    cell phone repair in Novi
    phone repair in Novi
    tablet repair in Novi
    ipad repair in Novi
    mobile phone repair Novi
    iphone repair Novi
    cell phone repair Novi
    phone repair Novi

    ReplyDelete
  3. Operating from home can certainly be called telecommuting, which suggests working from an isolated location which often refers to the home office. remote work templates

    ReplyDelete
  4. I found your this post while searching for information about blog-related research ... It's a good post .. keep posting and updating information. https://europa-road.eu/hu/magas-szinvonalu-gepszallitas-budapest.php

    ReplyDelete

Popular Posts