First published on TECHNET on Nov 30, 2010
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{6ef191ce-3124-2974-94fb-020c677f4017}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{76480d55-a19d-7cef-4446-0f1ccaef11ce}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Or>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{6ef191ce-3124-2974-94fb-020c677f4017}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{76480d55-a19d-7cef-4446-0f1ccaef11ce}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
First let’s make sure we understand some logical concepts related to criteria. If I say the criteria for selecting a movie is:
Rating is greater than 4 stars
MPAA rating is not equal to Rated R
Genre is Comedy, Action, Drama
I am not being clear enough about what my criteria is. Do I mean that the movie can meet any of those criteria and be acceptable? Or do I mean that the movie must meet all of those criteria? Does the movie have to be Comedy, Action, and Drama all in one?
What if I was more specific in my criteria and said:
(Rating is greater than 4 stars
AND
MPAA rating is not equal to Rated R
AND
(Genre is Comedy OR Action OR Drama))
If this was my criteria clearly something like Lord of The Rings: Two Towers would meet the criteria but something like Snakes on a Plane would not. Snakes on a Plane is not rated 4 stars or better and is Rated R. It could be considered an ‘Action’ movie or a ‘Comedy’ movie I guess depending on your point of view, but it doesn’t meet the other two criteria anyways so it’s out.
Now consider how grouping the clauses differently returns different results.
( Rating is greater than 4 stars
AND
MPAA rating is not equal to Rated R )
OR
(Genre is Comedy OR Action OR Drama)
With this criteria Snakes on a Plane could be considered to meet the criteria since it could be considered an action (or a comedy) movie and the movie either has to be a comedy, action or drama movie OR be both a 4+ stars movie an not rated R.
Now let’s apply this concept to workflow/subscription criteria…
When you are creating notification subscription criteria in the console each criteria that you add to the criteria builder is AND’ed together with other criteria. For example I could say ‘when an incident is created and the source = Portal and the title contains ‘foo’ and the urgency = high like this:
If I want to I can OR multiple list values from the same list together by adding the list data type property to the criteria more than once and choosing different list values like this:
This is equivalent saying this:
(Source = Portal
AND
Title contains ‘Foo’
AND
(Urgency is High OR Medium))
Now – here is some criteria that a customer was trying to do:
The customer’s intention was to fire the workflow whenever the incident matched this criteria:
Source Does Not Equal ‘Portal’
AND
Source Does Not Equal ‘Console’
In other words ‘fire if source is anything except portal or console’. But because the criteria is OR’d together when you use multiple values from the same list it looks like this:
Source Does Not Equal ‘Portal’
OR
Source Does Not Equal ‘Console’
So – let’s take some examples – if the source is ‘Portal’ will this workflow be triggered? Yes! Because while it doesn’t meet the criteria in the first clause it does meet the criteria in the second clause and since they are OR’d together only one of them must be true to fire the workflow. What if the source was ‘Console’? The criteria would be met by the first criteria but not the second and so it would fire. It would also fire if the source were ‘Email’ since it matches both criteria. This is clearly not what the customer intended. What to do?
Two options:
1) Since you are dealing with a finite set of sources you could create your criteria to look like this instead:
Source Equals ‘Email’
OR
Source Equals ‘Compliance’
OR
Source Equals ‘Phone’
OR
Source Equals ‘Configuration Manager (DCM)’
OR
Source Equals ‘System’
OR
Source Equals ‘Operations Manager’
Basically you are matching any criteria other than Console or Email. That works in some cases where you have a relatively short finite list of items but it has some drawbacks. If you ever added a new source to the list you would need to remember to update this criteria to include an OR clause for that as well. It’s a little harder to tell at a glance what the conceptual intention of the criteria is. Remember the conceptual intent of the criteria was to do something if the source was anything but Console or Portal.
2) You can export out the MP and change the XML from this:
<Or><Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{6ef191ce-3124-2974-94fb-020c677f4017}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{76480d55-a19d-7cef-4446-0f1ccaef11ce}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Or>
to this:
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{6ef191ce-3124-2974-94fb-020c677f4017}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<Property State="Post">$Context/Property[Type='CustomSystem_WorkItem_Incident_Library!System.WorkItem.Incident']/Source$</Property>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value>{76480d55-a19d-7cef-4446-0f1ccaef11ce}</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
Then, reimport the MP.
You can get MUCH fancier about your and/or criteria in XML than the UI will allow you for now. We’ll try to expand the possibilities of what the UI can handle in future releases but for now this is all you can do:
1) AND criteria from multiple properties together (e.g. Title contains ‘Foo’ AND Source equals ‘Email’)
2) OR list values from a single list together (e.g. Source equals ‘Email’ OR Source does not equal ‘Portal’ OR Source equals ‘Operations Manager’)
If you need more complicated criteria than that you can set up virtually anything in the XML as far as AND/OR criteria goes.
Updated Mar 11, 2019
Version 4.0System-Center-Team
Microsoft
Joined February 15, 2019
System Center Blog
Follow this blog board to get notified when there's new activity