web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Running workflows manually

(0) ShareShare
ReportReport
Posted on by

Hi,

Workflow process that run in the background starts based on a criteria, such as "When record is created", or Status change, field change etc.

But is there a way to run these manually? I.e. not based on the criteria but maybe a button I push to just "Run" the workflow against all records?

If there isn't a straight forward feature of doing this - what are some good workarounds? To quickly do this for 500ish records.

Thanks in advance,

Regards,

C

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Peter72 Profile Picture
    1,815 on at

    Select the Checkbox "as on-demand process" in the workflow Definition. The workflow will then be available on forms and views. Change your personal Settings to Show 250 records per page, if you do not have done it already. Then you are able to select 250 records and start the workflow for them.

    1072.onDemandWorkflow2.jpg

    6837.onDemandWorkflow3.png

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Chon,

    Can you please confirm the version of CRM you are using?

    Have you had a chance to look into the CRM On-Demand workflows? I think that you meet your requirements.

    If you are using CRM 2013, you might want to consider On demand ,real time workflows.

    For more details about the workflows please refer msdn.microsoft.com/.../dn531067.aspx

    For more details about the creating Real-Time Workflows please refer, msdn.microsoft.com/.../dn481598.aspx

    Have fun.

    Cheers,

    Vivek

  • Community Member Profile Picture
    on at

    Thank did it, thanks

  • Fran Napoli Profile Picture
    5 on at

    Hello,

    I created a on-demand process. I would like to simply run it to update 5,000+ records. The process includes the criteria for the records.

    Is there a way to run it manually or, if that's not possible, to schedule it to run?

    Thank you.

    Fran

  • Suggested answer
    Red Hodgerson Profile Picture
    on at

    Hi Fran,

    You're best bet is to either run it in chunks of 250 records at a time, as mentioned above,  or create a small utility using the SDK to trigger the workflow across 5000+ records.

  • Community Member Profile Picture
    on at

    Hi Red,

    This is sorted now but I'm interested in being able to run these workflows for 5000+ records at a time, but I have no experience with SDK. Would you be able to refer some resources that I can follow?

    Thanks,

    C

  • Suggested answer
    PS Profile Picture
    23,577 on at

    Create a workflow & checkmark on demand:

    After that go to the respective records grid and click on '...' select run workflow

  • Suggested answer
    PS Profile Picture
    23,577 on at
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Chon,

    To execute workflow for more records, you can use SDK, you can refer to this snippet.

    *You would need to create a ExecuteWorkflowRequest message

    Example:

    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()

                       {

                           WorkflowId = _workflowId,

                           EntityId = _leadId

                       };

    Source:

    msdn.microsoft.com/.../gg309600.aspx

    msdn.microsoft.com/.../microsoft.crm.sdk.messages.executeworkflowrequest.aspx

    My suggestion:

    Put this code:

    // Create an ExecuteWorkflow request.

    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()

    {

       WorkflowId = _workflowId,

       EntityId = _leadId

    };

    // Execute the workflow.

    ExecuteWorkflowResponse response =

       (ExecuteWorkflowResponse)_serviceProxy.Execute(request);

    Under your looping, for or foreach.

    Make this as dynamically...

    _leadId

    This is will be your requested entity record id that you want to execute against it.

    First of all, you need to retrieve all the records, for example retrieve all lead, using QueryExpression or using fetchxml.

    Then using Retrieve Multiple request.

    See this:

    msdn.microsoft.com/.../microsoft.xrm.sdk.iorganizationservice.retrievemultiple.aspx

    For example:

    // Retrieve the related opportunity products

    QueryExpression recordQuery = new QueryExpression

    {

       EntityName = Lead.EntityLogicalName,

       ColumnSet = new ColumnSet("leadid", "name"),

       Criteria = new FilterExpression

       {

           Conditions =

       {

           new ConditionExpression

           {

               AttributeName = "statuscode", //for example only active Lead

               Operator = ConditionOperator.Equal,

               Values = { "Active" } //or SomeEnum.Active.ToString() if you want use good practice // or can be int 0

           }

       }

       }

    };

    DataCollection<Entity> records = _serviceProxy.RetrieveMultiple(

       recordQuery).Entities;

    foreach (Entity entity in records)

    {

       Lead lead = (Lead)entity;

       Console.WriteLine("Retrieved Lead{0}",

           opportunityProduct.Name.ToString());

      _leadId = lead.LeadId;

      // Create an ExecuteWorkflow request.

      ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()

      {

          WorkflowId = _workflowId,

          EntityId = _leadId

       };

       // Execute the workflow.

       ExecuteWorkflowResponse response =

          (ExecuteWorkflowResponse)_serviceProxy.Execute(request);

    }

    //or you can use late bound

    Sorry if there are some typo since I type in directly in this editor, not using C# editor :)

    Just to give the concept there, not a real exact code.

    Hope this helps.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans