function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mark azmark az 

Task Subject / WF rule / Contains

Hello, everyone.  I am trying to create a workflow rule that looks for the string 'SIA' in the subject of a task.  I set this up as " SIA " so that it would only flag this string, and not include it if it was part of another word (ie., don't flag 'Asia', for instance).  I used 'contains' as the rule criteria.

 

However, when I run the rule, it is incorrectly flagging tasks that have sia anywhere in the subject line.  If the subject is 'test SIA test', it works like I would expect.  If the subject is 'test ASIA test', though, it is catching and flagging this as well. 

 

I tried creating a more complex rule that said 'CONTAINS(TEXT(Subject)," SIA "), but when I try to save it I get a strange error about how text expects a number or date, but not a picklist.  I saw that others in the boards had a similar problem with a workflow rule trigger, but couldn't find any other solutions to this.


Does anyone have any thoughts?  Thanks in advance.

TheIntegratorTheIntegrator

simply use CONTAINS(Subject," SIA ")

mark-azmark-az

Sorry, I should have mentioned that I tried this.  My workflow rule has a field update that just sets a checkbox if this criteria is met.  I have an OR condition, so it looks like this in the 'criteria are met' layout"

 

Type starts with SIA

Subject contains " SIA " --> doing it this way, workflow seems to ignore the spaces on either side, and anything with the letters 'sia' anywhere in the subject gets flagged

 

I changed it to 'formula evaluates to true', and didn't even try to include the OR logic - just said 'CONTAINS(Subject, " SIA "). 

 

It saves ok, but it doesn't work when I test it out.  It isn't flagging anything.  I was trying the 'TEXT' to see if that would treat it any differently, and that throws the error 'Incorrect parameter for function TEXT()...'

 

I thought about setting the trigger to record type and trying to move the formula down to the field update, but since it's just a checkbox, I can't do that without changing the field type.

TheIntegratorTheIntegrator

I did create a workflow on task with rule criteria

Rule Criteria CONTAINS(Subject," SIA ")


and evaluation criteria

When a record is created, or when a record is edited and did not previously meet the rule criteria

 

I have a field update on Comment to put text "Match" when the workflow runs

 

I then create a new task with subject "test SIA test" and empty comment, on save, the comment gets populated with "Match"

 

I then edit this task, change the subject to "test ASIA test" and empty the comment again, on save the comment remains empty. Seems to work for me.

 

Could you check if this works for you? I know I always forget to make sure the workflow is active, so I'll ask you to check on that as well just to cross out the possibility.

mark-azmark-az

Thanks for the info - I have good/bad news.  The good news is that when I went back through and retested it, figured out what I was doing wrong, somewhat.

 

The rule said CONTAINS(Subject," SIA "), but my test task just said 'test sia test' in the subject line.  When I went back and changed it to 'test SIA test', it flagged it correctly.  My apologies for this, and thanks for the catch.  It was driving me nuts.

 

However, in an interesting wrinkle, I can't get it to flag the lower case version (test sia test).  I have tried with the colon (CONTAINS(Subject," SIA : sia ") - found this in the forums.  Have also tried with an OR condition (CONTAINS(Subject," SIA ") || CONTAINS(Subject," sia "), and the upper case version consistently works, but the lower won't flip the switch.

 

I'm sorry, I know this is a really simple thing and am sure I'm missing something basic, but can't quite figure it out.  Any ideas would be appreciated, and thanks again.

TheIntegratorTheIntegrator

try CONTAINS(LOWER(Subject)," sia ")

 

when you change the case of your subject and save, make sure you change some text otherwise the workflow criteria does not kick in as it does not consider case change a change in field.

mark-azmark-az

Ah, thank you very much.  The combination of things seems to have finally done it.  Something was wrong with my id yesterday, so I can't flag your answer as the solution, but you're right and this works.

 

My final criteria looks like this:

 

CONTAINS(Subject," SIA ") || CONTAINS(LOWER(Subject)," sia ") || ISPICKVAL(Type,"SIA Presentation Materials")

 

Thank you again for all of your help.

TheIntegratorTheIntegrator

no problem, glad it works.

 

Whenever you can, do mark it as completed as it helps others to find a solution.