Friday, September 07, 2007

Activate a Workflow using Javascript

Workflows are a great tool. They are quite simple to create, even non-programmers can actually create them and they are flexible. However, there are some problems with workflows in CRM 3 (how workflows are handled in Titan/CRM 4 will be interesting to see) for instance, a workflow cannot be activated when an entity is updated, only when it is created, when it changes status, when it changes owner and of course, manually.

Mitch Milam has written an interesting post on his blog concerning how to activate a workflow using javascript. You can read about it here: http://blogs.infinite-x.net/2007/06/15/launching-a-workflow-rule-from-javascript/.

A bit of caution is however advised. I would actually prefer to have the workflow being activated by a PostUpdate-callout instead, to make sure that it is only run once. Activating a workflow on the on-change event can be a bit hazardous since it is very possible that the event is triggered several times on the same form before it has been saved.

Never the less, it is a good posting and can probably give you an idea or two about how to programmatically activate CRM workflows. If I wasn't block from using my own virtual directory or website with my own aspx-files, I would also prefer to trigger the workflow from an aspx-page and call the aspx-page using AJAX. Have a look at the class ExecuteWFProcessRequest in the CRMSDK as it enables you to execute a workflow using the web service.

Gustaf

1 comment:

  1. Sir,

    How about activating a javascript using a workflow?

    Thanks,

    Larry

    ReplyDelete