Business Rule

Printer-friendly version    Send to friend    2 replies
Davin Johnson
User offline. Last seen 5 weeks 3 days ago.

 TFD,

It was nice finally meeting you out at Catalyst.

 I’ve got a rule question.  I’ve written an ugly rule that does all but the one function.  I have a hard time going back and cleaning up a rule once I’ve added to it several times.

IFBLANK(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(PROPER(REPLACE($DEPARTMENT3,"Gender/","")),"'",""),"youth","Male"),"Womens","Female"),"Mens","Male"),"Kid's","Child"),"Male"))

So I have six replaces, can/should this be reduced to one replace function?  If so can you show me the re-written rule?  Also my fifth replace isn’t working   ,"Kid's","Child")  can you see why the others are functioning properly but not the fifth?

Thanks,
Davin

0
Your rating: None
ChannelAdvisor Employee
Anthony Alford's picture
User offline. Last seen 1 week 2 days ago.
RE: Business Rule

 Hi Davin,

Definitely enjoyed meeting you at Catalyst; we'll have to do it again next year :)

Ok, on your rule, you might try using REPLACEWORDLIST. What you do is create a lookup list that has on the left the words you want to replace, and on the right the ones you want to put in. So, you'd have:
youth       Male
Womens  Female
Mens       Male
etc.

Then you use it like this:

REPLACEWORDLIST("the name of the list",$DEPARTMENT3)
 

A couple of things to keep in mind. I am pretty sure this is can sensiive, so Youth wouldn't match youth, for example. Also, it only works on full words, so that "mens" wouldn't get replaced inside "Womens," which is probably the way you want it to work. 

I'm not sure why the "Kid's" replace doesn't work. I'd say try out the new way, using REPLACEWORDLIST, and then let me know if it's still a problem.

Davin Johnson
User offline. Last seen 5 weeks 3 days ago.
RE: Business Rule

 That did the trick...Thanks!