none
Nested IIF statements RRS feed

  • Question

  • I have a (not very elegant) idea for setting a MV attribute based on the presence of a string in the DN of a user that is being imported.
    I got the following from another post, can't remember where. This is a work-around for not having a function that searches for a string within another string. Basically, if the DN contains "sales department", flow "Sales Department" to an attribute.

    IIF(NotEquals(ReplaceString(dn,"Sales department",""),dn),"Sales department","Other department")

    That works fine. There are obviously a few departments, so I want to nest the IIF statements.
    I would expect this to work:

    IIF(NotEquals(ReplaceString(dn,"sales department",""),dn)),"sales department",IIF(NotEquals(ReplaceString(dn,"accounts department",""),dn)),"accounts department","another department"

    But it doesn't. When inputting the flow definition, I get "The function IIF is not correctly formatted".
    Is there a limitation to nesting of IIF statements in custom expressions?

    The other way I can think of to do this is to add a bit of compiled code that references an array of "allowed departments" from a text file.

    Many thanks!
    John

    Wednesday, April 20, 2016 8:03 AM

Answers

  • Should work - I think you have one too many ) after each "dn"... so try:

    IIF(NotEquals(ReplaceString(dn,"sales department",""),dn),"sales department",IIF(NotEquals(ReplaceString(dn,"accounts department",""),dn),"accounts department","another department"))

    • Marked as answer by niceshark Tuesday, May 3, 2016 1:30 AM
    Friday, April 29, 2016 1:27 PM

All replies

  • Yes, nested IIF statements in FIM/MIM is a bit quirky. The parser really needs a re-take.

    For our latest nested IIF statement problem we had to resort to a Rules Extension.

    You could try rewriting the statement to get it to work. Sometimes that gets you there. Sometimes you have to resort to either a Rules Extension, or handling it in a Workflow.


    Did my post help? Please use "Vote As Helpful", "Mark as answer" or "Propose as answer". Thank you!

    Thursday, April 21, 2016 7:07 AM
  • Thanks Leo,

    Maybe they'll re-write the parser for MIM. Oh wait - this is MIM ;-)

    I tried a few other options in the statement, but no joy. I guess I'll add another rules extension and take another step back from Declarative Nirvana.

    John

    Thursday, April 21, 2016 11:47 PM
  • Haha, yeah, this in MIM. The logo has changed.

    But wait - it still says Forefront Identity Manager in the About dialog ;)

    Happy Rules Extensioning!


    Did my post help? Please use "Vote As Helpful", "Mark as answer" or "Propose as answer". Thank you!

    Friday, April 22, 2016 6:23 AM
  • Should work - I think you have one too many ) after each "dn"... so try:

    IIF(NotEquals(ReplaceString(dn,"sales department",""),dn),"sales department",IIF(NotEquals(ReplaceString(dn,"accounts department",""),dn),"accounts department","another department"))

    • Marked as answer by niceshark Tuesday, May 3, 2016 1:30 AM
    Friday, April 29, 2016 1:27 PM
  • By jove, I think he's got it! :-) Thanks.

    These custom rules are not very forgiving. I'll be more careful next time before asking.

    Tuesday, May 3, 2016 1:30 AM
  • No problem :)
    Tuesday, May 3, 2016 12:14 PM