How To

Business Rules Best Practices

Below are some best practices to keep in mind when working with business rules. Need more help with business rules, or have questions?  Check out the SSC Forums.

 

Prerequisites


You should be familiar with the following topics:

 

Syntax Best Practices



  • CAPITALIZE FUNCTIONS:  Function names are always capitalized.   Example :  PROPER()  
  • INVENTORY FIELDS:  Inventory field names begin with $, are lowercase, and contain no spaces or special characters.   Example :  $itemtitle  
  • TEXT IN QUOTES:  Always enclose literal text strings in double-quotes.   Example :  "Blue Jacket"  
  • MATCH PARENTHESES:  Make sure the number of opening parentheses matches the number of closing parentheses.   Example :  PROPER(TRIM($itemtitle))  
  • LOOKUP LISTS:  When referencing Lookup Lists using functions, the Lookup List names are case-sensitive and have to match EXACTLY, including spaces.  Note that values within the Lookup Lists themselves are not case-sensitive.   Example :  If your list is named "My List": 

INCORRECT CORRECT
LOOKUP("my list",$itemsku)
LOOKUP("My List",$itemsku)
LOOKUP("MyList",$itemsku)

 

 

 

 

 

 

 

 

 

General Best Practices



  • BACKUP BEFORE EDITING:  If editing an existing rule, be safe and copy a backup of the previous version in the Description field before editing. 
  • PREVIEW BEFORE SAVING:  Preview rules before saving to ensure they work how you're expecting. 
  • DESCRIPTION FIELD:  Use the Description field to describe rule functions, make notes, save previous versions of rules, and write out algorithms. 
  • USE DESCRIPTIVE NAMES:  Name rules descriptively.   Example :  Filter Items < $5  
  • DON'T FORGET SPACES:  When using the CONCATENATE or JOIN functions, don't forget to include spaces if necessary.   Example :  CONCATENATE ("Hello"," ","there")  
  • QUOTATION MARKS:  Since quotation marks (quotes) are special characters, you'll need to use backslashes when including quotes in your text strings.   Example :  "This \"word"\ will be quoted."


Tips & Tricks


  • UTILIZE LOWERCASE():  To ensure accurate string matching, convert strings to lowercase before evaluating.   Example :  IF(TOLOWER($brand)="acme","free shipping","$4.99")  
  • RE-USE RULES:  If possible, utilize the same rule on multiple templates rather than creating separate rules that do the same thing. 
  • NEST FUNCTIONS:  Nest functions within other functions for maximim efficiency.   Example :  IF(TOLOWER($brand)="acme","free shipping","$4.99")  
  • INVERT TRUE/FALSE:  To invert boolean values (switch true to false and false to true), enclose rules in the NOT function.   Example :  NOT(2 > 1) will return a value of FALSE.  
  • REGULAR EXPRESSIONS:  Utilize Regular Expressions within rules to perform advanced functions.   Example :  REGEXREPLACE( $offername, "&[a-zA-Z0-9]+;", "" )

 

Below are some best practices to keep in mind when working with business rules. Need more help with business rules, or have questions?  Check out the SSC Forums.

 

Prerequisites


You should be familiar with the following topics:

 

Syntax Best Practices



  • CAPITALIZE FUNCTIONS:  Function names are always capitalized.   Example :  PROPER()  
  • INVENTORY FIELDS:  Inventory field names begin with $, are lowercase, and contain no spaces or special characters.   Example :  $itemtitle  
  • TEXT IN QUOTES:  Always enclose literal text strings in double-quotes.   Example :  "Blue Jacket"  
  • MATCH PARENTHESES:  Make sure the number of opening parentheses matches the number of closing parentheses.   Example :  PROPER(TRIM($itemtitle))  
  • LOOKUP LISTS:  When referencing Lookup Lists using functions, the Lookup List names are case-sensitive and have to match EXACTLY, including spaces.  Note that values within the Lookup Lists themselves are not case-sensitive.   Example :  If your list is named "My List": 

INCORRECT CORRECT
LOOKUP("my list",$itemsku)
LOOKUP("My List",$itemsku)
LOOKUP("MyList",$itemsku)

 

 

 

 

 

 

 

 

 

General Best Practices



  • BACKUP BEFORE EDITING:  If editing an existing rule, be safe and copy a backup of the previous version in the Description field before editing. 
  • PREVIEW BEFORE SAVING:  Preview rules before saving to ensure they work how you're expecting. 
  • DESCRIPTION FIELD:  Use the Description field to describe rule functions, make notes, save previous versions of rules, and write out algorithms. 
  • USE DESCRIPTIVE NAMES:  Name rules descriptively.   Example :  Filter Items < $5  
  • DON'T FORGET SPACES:  When using the CONCATENATE or JOIN functions, don't forget to include spaces if necessary.   Example :  CONCATENATE ("Hello"," ","there")  
  • QUOTATION MARKS:  Since quotation marks (quotes) are special characters, you'll need to use backslashes when including quotes in your text strings.   Example :  "This \"word"\ will be quoted."


Tips & Tricks


  • UTILIZE LOWERCASE():  To ensure accurate string matching, convert strings to lowercase before evaluating.   Example :  IF(TOLOWER($brand)="acme","free shipping","$4.99")  
  • RE-USE RULES:  If possible, utilize the same rule on multiple templates rather than creating separate rules that do the same thing. 
  • NEST FUNCTIONS:  Nest functions within other functions for maximim efficiency.   Example :  IF(TOLOWER($brand)="acme","free shipping","$4.99")  
  • INVERT TRUE/FALSE:  To invert boolean values (switch true to false and false to true), enclose rules in the NOT function.   Example :  NOT(2 > 1) will return a value of FALSE.  
  • REGULAR EXPRESSIONS:  Utilize Regular Expressions within rules to perform advanced functions.   Example :  REGEXREPLACE( $offername, "&[a-zA-Z0-9]+;", "" )

 

0
Your rating: None
0
Your rating: None