AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.03.2012, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
Leon's CRM Musings: Using An ‘OR’ Condition In Workflows
Источник: http://leontribe.blogspot.com/2012/0...workflows.html
==============



The Problem

One of the problems with workflows is that,while you can group conditions with an OR in Advanced Find, you do not have the same ability within workflows.

Here are the advanced find grouping buttons.



Here is the workflow box for a ‘Check Condition’ step.



We can list multiple conditions but these are automatically grouped with an ‘AND’ clause i.e. all must be fulfilled.

This issue has come up in the forums in the past and, usually I recommend the creation of two workflows: one for each condition. While this approximates an ‘OR’ it is a lot of work.

The problem with this solution is we now have two workflows to maintain which means more overhead.

An Alternative Solution

De Morgan’s Law tells us that ‘A OR B’ is logically equivalent to NOT (NOT A AND NOT B). So how does this help us?

Well, to deal with the first ‘NOT’ we use the ‘Default Action’, which gives us an ‘Otherwise’ to our ‘If-Then’



Therefore, if we say ‘if (NOT A AND NOT B) then do nothing otherwise do x’ we have a winner.

So, in practice, let us say we want the workflow to trigger if either of one of two tickboxes are ticked. For an advanced find it is east to find records where Tickbox A or Tickbox B has been ticked.



For our workflow it is going to read thus:



If we trigger this off of the two fields changing, if neither of the fields are ticked, nothing happens but if either or both are ticked our action happens, which is what we want.

Doing the Maths

If you have a more complex problem, this is how to approach it.

First of all we have De Morgan’s Law: A OR B = NOT (NOT A AND NOT B)

Let us define our logical tests:

A: Tickbox A = Yes
B: Tickbox B = Yes

Therefore:

NOT A: Tickbox A = No
NOT B: Tickbox B = No

So Tickbox A = Yes OR Tickbox B = Yes is equivalent to NOT (Tickbox A = No AND Tickbox B = No) and this is expressed as we saw above using an if-then-otherwise step.



Conclusions

Using this technique, while a little harder to read (although the comment line can help) we maintain just one workflow, saving on future administration.  The technique is also applicable to any condition which there is a straightforward ‘opposite’ version of and can be extended to multiple attributes, not just two, without having to resort to creating multiple, mostly identical workflows.




Источник: http://leontribe.blogspot.com/2012/0...workflows.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Leon's CRM Musings: Book Review: Microsoft Dynamics CRM 2011 Administration Bible Blog bot Dynamics CRM: Blogs 0 19.12.2011 12:11
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 4 Blog bot Dynamics CRM: Blogs 0 24.09.2011 01:16
Leon's CRM Musings: Dynamics CRM Resources for the Rest Of Us Blog bot Dynamics CRM: Blogs 0 06.11.2010 03:11
Leon's CRM Musings: Book Review: Teach Yourself Microsoft Dynamics CRM 4 in 24 Hours Blog bot Dynamics CRM: Blogs 0 21.07.2010 09:06
CRM DE LA CREME! Configuring Microsoft Dynamics CRM 4.0 for Internet-facing deployment Blog bot Dynamics CRM: Blogs 0 18.08.2009 11:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:30.