Recently I needed to extend a simple outbound sync rule (FIM 2010 R1) to provision a business email address to an HR system. In the target HR system, multiple contact records can be recorded for a user, and under normal conditions a “business” contact was to be set with the exchange email address from AD. However, in a test environment where “new starter” emails are to be sent from the HR system I didn’t want to use “real” email addresses but a test mailbox instead.
I figured I simply needed a means of overriding an EAF in a sync rule with a constant email address – purely to support my testing needs. Under normal circumstances there should be no override, so I figured I could use a workflow parameter and only set a value in the test scenario. The override idea seemed to work well – I could have identical sync policy in each of my DEV/TEST/PROD environments, but this way I could support this testing requirement without having to actually change the sync rule itself. Test emails were indeed sent to the test mailbox as required.
I set up my EAF in my sync rule like this (CS and MV prefixes for explanatory purposes only):
CS.email = IIF(Eq(Trim($EmailOverride),""),MV.email,$EmailOverride)
It seemed like a perfectly reasonable thing to expect to work – I assumed that if I simply didn’t supply any parameter value when I added the sync rule to the target user object, that the above logic would result in Eq(Trim($EmailOverride) returning a TRUE value. I was wrong …
I only noticed there was a problem when I removed the override value and noticed that the pending exports subsequently produced had no email address value at all! This broke my HR exports and indicated that I had a lingering problem with the above EAF. This was confirmed when I compared the corresponding ERE for two different users – one created when the constant email value was present (which worked), and one when the value was removed (which failed). What I noticed was that there was only an XML value in the Synchronization Parameter binding on the ERE when there was a value specified on the workflow which attached my sync rule. When I specified an override email I ended up with this in the SR parameter :
<sync-parameter><name>EmailOverride</name><value>dummy.mailbox@mydomain.com</value></sync-parameter>
… but when there was no value specified, rather than getting this:
<sync-parameter><name>EmailOverride</name><value></value></sync-parameter>
… I actually got no SR parameter at all (i.e. no XML whatsoever). This was not what I expected, and explained why my EAF wasn’t working.
I then tried each of the following without success:
- Eq($EmailOverride,Null())
- IsPresent($EmailOverride)
I finally had to settle for this:
CS.email = IIF(Eq(Trim($EmailOverride),”NONE”),MV.email,$EmailOverride)
and resort to having to specify “NONE” as my default workflow parameter rather than an empty string.
So the upshot of this post is to make the point that (for FIM2010 R1 at least) there is effectively no such concept as an “optional sync rule parameter”. Why? Because there doesn’t appear to be a way to successfully test for the (lack of) presence of a value in a parameter.
I would be interested to find out if anyone has observed this same behaviour for R2?