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
SadieSadie 

Description Formula

Hello,

 

I am new to SalesForce. We are trying it out to see if it is what we are looking for.  We have already created sku's on our website to pass through to SalesForce when a payment is complete.  I have set up an auto email to send to customers with their billing address, ammount etc.  What is throwing me for a loop is this. We have multiple sku's on our site as we sell hundreds of products.  What I am trying to do is add a description with the sku. So when customer "A" orders 1 Raspberry Ketone from our site right now it passes as 1:RBKVTL. I have this added to the email already. What I want to add is somethign like "If the sku shipped contains RBKVTL description is "Raspberry Ketone". But I need to do this for all of my products.  This is what I have so far:

 

IF(CONTAINS(Sku_Shipped_1__c, "green"), "Green Coffee", "Green Coffee") 

IF(CONTAINS(Sku_Shipped_1__c, "RBKVTL"), "Raspberry Ketone", "Raspberry Ketone")

 

This is obviously wrong as every email passes through "Green Coffee Rapsberry Ketone" no matter what they order.

 

Thanks in advance for the help, please be gentle with me :)

 

Sadie

Best Answer chosen by Admin (Salesforce Developers) 
HarshalHarshal

Hi Sadie,

 

When you use the "IF" function the first string is returned if the condition is met (true) or the second string will be returned if the condition is not met(false).  In you're case  IF(CONTAINS(Sku_Shipped_1__c, "green"), "Green Coffee", "Green Coffee") since you put "Green Coffee" in both the true and false they will both return in all situations.  You need the change the second "Green Coffee" to either false(w/o) quotes or empty quotes.

All Answers

HarshalHarshal

Hi Sadie,

 

When you use the "IF" function the first string is returned if the condition is met (true) or the second string will be returned if the condition is not met(false).  In you're case  IF(CONTAINS(Sku_Shipped_1__c, "green"), "Green Coffee", "Green Coffee") since you put "Green Coffee" in both the true and false they will both return in all situations.  You need the change the second "Green Coffee" to either false(w/o) quotes or empty quotes.

This was selected as the best answer
Justine HeritageJustine Heritage

Hi Sadie,

 

Depending on how many products you have, you will be better off using the CASE function for your description field like so:

 

CASE( Sku_Shipped_1_c,

    "RBKVTL", "Raspberry Ketone",

    "SKU 2", "Description 2",

    "SKU 3", "Desctiption 3",

    .

    .

    .

    "Error: product not found" )

 

The case statement takes in the field you are examining as the first parameter (in this case, the SKU). The second parameter is a possible value for that SKU ("RBKVTL"), and the third parameter is the description for that specific SKU ("Raspberry Ketone"). This pattern continues for all of your products, and if the SKU isn't found, you can print some error message as the final parameter.

 

Again, if you have a lot of products you may have trouble with the size of your formula (there is a 3900 character limit). Give this a try though and see if it helps!

SadieSadie

Thank you, that did the trick!!

SadieSadie
Thank you for your help. It is appreciated.
asg aseasg ase
Thanks for sharing this scripts. I will test it on my page of coffee roaster machine reviews (https://machinescraft.com/best-coffee-roaster-machine-for-small-business/),