I had a recent experience helping a customer and implementer in dealing with a lot of workflows and field validations combined with integration via web services. It occurred to me some folks out there might be attempting the same, so I decided to write up a few tips which could save some headaches!

The ExcludeChannel() Function

This function allows you to tell CRM On Demand to ignore inputs that come from a specific channel. For example, let’s say you have workflow that sends an e-mail to a record Owner when new records are created. But you don’t want it to do so if the insert is coming through a web services integration.

Adding ExcludeChannel(‘Web Services’) will prevent the workflow from firing and stop the Send E-mail action.

What’s really happening?

Whenever working with Expression Builder in workflow, field validation or default values, it’s important to understand what’s really happening when an expression is evaluated. This can help you a lot in troubleshooting when things don’t seem to be working quite right.

The first thing to understand is what the expression returns. Most expressions will give you a value of some sort as a result. This could be a string, an integer or, in this case, a boolean. Boolean values are True or False – if you convert this to a string, it’s “Y” or “N”.

ExcludeChannel returns a boolean “Y” or “N”. Here’s how our function works with ExcludeChannel(‘Web Services’) as the Workflow Rule Condition:

Function: ExcludeChannel('Web Services')
Result: if channel = 'Web Services' then return 'N' else return 'Y'

Workflow conditions look for a Boolean value. Whatever combination of formulas you have in your criteria, they have to result in a Y or N. An “N” tells it the conditions are not met, so don’t do anything. A “Y” tells it the conditions are true, so go ahead and perform the action.

To prevent a workflow from firing when the input channel is web services, we need to make sure our condition formula evaluates to “N”.

Simple enough, right?

Maybe, but keep in mind that this can get decidedly more complex in more elaborate conditions. Take this one for example:

(UserValue('<Role>')="Administrator" AND [<Priority>]= LookupValue("ACCOUNT_PRIORITY", "High")) OR [<AccountType>]= LookupValue("ACCOUNT_TYPE", "Prospect")

Ok, so not terribly complex, but still a bit going on here. Which of the below is correct to prevent this condition from being true if triggered by web services?

#1:  ((UserValue('<Role>')="Administrator" AND [<Priority>]= LookupValue("ACCOUNT_PRIORITY", "High")) OR [<AccountType>]= LookupValue("ACCOUNT_TYPE", "Prospect")) AND ExcludeChannel('Online')

#2: ((UserValue('<Role>')="Administrator" AND [<Priority>]= LookupValue("ACCOUNT_PRIORITY", "High")) OR [<AccountType>]= LookupValue("ACCOUNT_TYPE", "Prospect")) OR ExcludeChannel(‘Web Services’)

Answer: #1. The second formula basically says if any of these three conditions are true then go ahead. The first one says one has to be true AND the channel can’t be web services.

Generally, you will use the “AND ExcludeChannel()” syntax in your workflow conditions.

What about Field Validation?

Here’s where it gets interesting (well, to me at least). If we use the same formula in our Field Validation rule on the Account Type field:

((UserValue('<Role>')="Administrator" AND [<Priority>]= LookupValue("ACCOUNT_PRIORITY", "High")) OR [<AccountType>]= LookupValue("ACCOUNT_TYPE", "Prospect")) AND ExcludeChannel(‘Web Services’)

This will work a bit differently. Whenever I change the Account Type value, it’s going to check a few things:

First: Is the current user an Administrator and is Priority = High?

  • Y or N
  • Second: Is the Account Type = Prospect?

  • Y or N
  • Finally: Is the Channel = Web Services?

  • Y or N
  • It’s important to understand how these are joined together as well. Based on the grouping, it will evaluate this way:

    ((Admin & high priority) OR (Prospect)) AND Exclude web services

    Now hold on! This is always going to FAIL validation when the input channel is web services.

    Remember, a field validation looks for a Boolean, just like a Workflow Condition. But to pass validation (and avoid an error message) we want the result to be “Y”. But because ExcludeChannel(‘Web Services’) will return “N” when triggered by web services, this validation will fail.

    So what works fine in Workflow has the opposite effect in Field Validation!

    Again, the key here is the Boolean value that you end up with. To prevent a workflow from firing, you want the condition to result in “N”. To prevent Field Validation from stopping you with an error, you want the expression to result in “Y”.

    How to always get your Field Validation to result in Y?

    We know that ExcludeChannel(‘Web Services’) will return “N” for a web services integration. Well, there is a handy operator that turns everything around – it’s called “NOT()”. If you put a Boolean expression in those parentheses, a Y becomes an N and vice versa.

    So let’s modify our Field Validation thusly:

    ((UserValue('<Role>')="Administrator" AND [<Priority>]= LookupValue("ACCOUNT_PRIORITY", "High")) OR [<AccountType>]= LookupValue("ACCOUNT_TYPE", "Prospect")) OR NOT(ExcludeChannel(‘Web Services’))

    Notice we also changed our AND to an OR. If any part of this expression evaluates as Y then it will pass validation. Because we know that NOT(ExcludeChannel(‘Web Services’)) will always be Y when integration updates the record, then this should always pass muster.


    While this post only discussed the Web Services channel, the same logic can of course be applied to Import, Online, and other channels supported by the ExcludeChannel function.

    For implementers, it is a good idea to determine early in your requirements if this kind of exception will be needed – it’s a lot easier to plan it out right from the start than to go back later and try to add in!

    Do you have any Expression Builder questions or tips of your own? Drop me a line!

    Share and Enjoy:
    • Digg
    • LinkedIn
    • del.icio.us
    • Facebook
    • Mixx
    • Google Bookmarks
    • Twitter
    • StumbleUpon
    • Technorati
    1. Mani on 02 Sep 10 11:01 pm

      Thank you for the share and excellent write-up! I ran into this issue recently. (especially with WF – Before Modified Record Event-Cancel Save)

    2. Justin on 14 Sep 10 7:56 pm

      Great stuff, keep it coming guys!

    3. Satish on 11 Feb 11 12:05 am

      Can we achieve the above using field validation ? If so hw… plz let me knw….TIA


    4. Louis Peters on 15 Feb 11 3:34 pm

      Yes, I address field validation in the blog entry. The key is to understand that you want field validation to return ‘Y’ in order for the value to be entered, while for workflow you want the condition to evaluate to ‘N’ if you don’t want the action to fire.

    5. Satish on 22 Feb 11 1:29 am


      Hw can we automatically active/inactive checkbox field when we create or modified records in the detail page. TIA


    6. Louis Peters on 22 Feb 11 10:07 am

      Hi Satish – Perhaps you can send a more detailed example of what you are trying to do to louis@crmondemandpodcast.com? Note that there is a long-standing issue with setting post-default values for a checkbox (it doesn’t work). I’m not aware of a problem on modification, however.

    7. Satish on 23 Feb 11 2:46 am

      Hi Louis,

      Thnx a ton for your quick reply.


    8. Thanks a ton LOUIS

      Nice topic on ExcludeChannel() Function

      Good learning for me.

    9. Satish on 28 Feb 11 6:29 am

      Hi Louis,

      I knw u hve done of tons of Field Validation & Workflows..
      Can u share which u felt very interesting & challenging.TIA