Google adds

FORMULA TRAILHEAD

How to append stars on lead object based on the no.of checkboxes checked by using formula field in salesforce.

 On lead object say I have 3 custom checkbox fields namely ch1__c,ch2__c and ch3__c.
  If anyone checkbox field is selected only one star has to be displayed on lead object.
  Similarly if any two checkbox fields are selected, two stars has to be displayed and 
  if any three checkbox fields are selected, three stars has to be displayed on Lead object.



1)Store the 1star, 2star, 3star images in documents and enable externally available image for all      the three document files.
2)Create custom formula field of type text and write the formula as below and save it.

Case((IF((ch1__c=false), 0, 1) + IF((ch2__c=false), 0, 1) + IF((ch3__c=false), 0, 1)),
1, IMAGE("https://------copy and paste the image source here-------", "give alternate text", length, width),
2, IMAGE("https://------copy and paste the image source here-------", "2 star", 60, 100),
3, IMAGE("https://------copy and paste the image source here-------", "3 star", 60, 100),
"0 stars")

Note: For image source just open document file right click on the image and copy the image address.
alternate text can be any name, length and width of the image can be set as required.

Tuesday, February 2, 2016

Create a validation rule indicating whether an opportunity has a closed date in the past.

Your number-crushing sales team has so many deals in the pipeline, you’re starting to see occasional problems with data quality. Namely, sales reps are forgetting to update the close date to a date in the future. Make a formula that requires an opportunity to have a CloseDate of today or any future date. Hint: this formula should reference the hidden IsClosed checkbox field on the Opportunity object, and you will be creating the formula as an Opportunity validation rule.
  • The validation rule should be on the Opportunity object
  • The validation rule should be named 'Close_Date_Alert'
  • The validation rule should fire if IsClosed is not selected and CloseDate is yesterday or earlier
  • The validation rule should display the error 'Hey McFly, unless you are planning to go back in time, please update your close date' at the top of the page when triggered


1) Create validation rule on opportunity object and make sure it is active while taking challenge.
2) Enter the below formula.

AND(NOT( IsClosed ),CloseDate < TODAY ())
3) Give the error message as

Hey McFly, unless you are planning to go back in time, please update your close date
Create a formula that returns the current day of the week.

To complete this challenge, use some of the strategies and function you learned in this unit to return the day of the week as a text string.
  • The formula should be on the Contact object
  • The formula should be of return type Text
  • The formula should be named 'Day of the Week' with the resulting API name 'Day_of_the_Week__c'.
  • The formula should return the day of the week as a string—”Monday,” “Tuesday,” and so on

1) Create one custom formula field on contact object of type text and enter the below formula.


CASE(MOD(Today()- DATE(1900,1,7), 7), 0, 'Sunday', 1, 

'Monday',2,'Tuesday',3,'Wednesday',4,'Thursday',5,

'Friday',6,'Saturday','error')



Create a formula field that returns an image to indicate data quality.

Sales Managers have asked for an at-a-glance solution to see completeness on leads. Create a helper formula field that looks at 5 key fields on the Lead object and evaluates their completeness, then a second formula field that references the helper formula and returns an image.
  • The helper formula field should be on the Lead object with a name of 'Lead Quality Helper' and a resulting API name of 'Lead_Quality_Helper__c'.
  • The helper formula should be of type Number.
  • The helper formula should evaluate the following 5 fields: Email, Phone, Company, Title, and Industry and return 0 if blank and 1 if not blank. The formula should then add all the values together to return a total value.
  • The image formula should be on the Lead object with a name of 'Lead Quality' and a resulting API name of 'Lead_Quality__c'.
  • The image formula should reference the helper formula, and return an image based on the number returned by the helper formula. The helper formula should be of type Text. Note: All of these images are already available in your Developer Edition.
    • 1 = /img/samples/stars_100.gif with alternate text '1 star'
    • 2 = /img/samples/stars_200.gif with alternate text '2 stars'
    • 3 = /img/samples/stars_300.gif with alternate text '3 stars'
    • 4 = /img/samples/stars_400.gif with alternate text '4 stars'
    • 5 = /img/samples/stars_500.gif with alternate text '5 stars'
  • If none of the fields are filled out, the default should be /img/samples/stars_000.gif with alternate text '0 stars'.
  • The 'Lead Quality' formula must be added to the Lead Layout page layout.


1) Create one custom 'Lead Quality Helper' formula field of type number on lead object and enter the below formula.

IF(ISBLANK(Email) , 0, 1) + IF(ISBLANK(Phone) , 0, 1) + IF(ISBLANK(Company) , 0, 1) + IF(ISBLANK(Title) , 0, 1) + IF( ISPICKVAL(Industry , ""), 0, 1)

2) Create one custom 'Lead Quality' formula field of type text on lead object and enter the below formula.


IMAGE( 

CASE( Lead_Quality_Helper__c , 

1, "/img/samples/stars_100.gif ", 
2, "/img/samples/stars_200.gif", 
3, "/img/samples/stars_300.gif", 
4, "/img/samples/stars_400.gif", 
5, "/img/samples/stars_500.gif", 
"/img/samples/stars_000.gif"), 
"0 stars")
Create a formula that shows where an Opportunity is in the pipeline.

Create a formula field that classifies an Opportunity as either “Early”, “Middle”, or “Late”. This formula field should use TODAY() to calculate what percentage of the time between an opportunity’s CreatedDate and CloseDate has passed, and label the opportunity accordingly.
  • This formula should be on the Opportunity object
  • This formula should be named 'Opportunity Progress' with the resulting API name Opportunity_Progress__c
  • This formula should return 'Early' if less than or equal to 25% of an opportunity has passed
  • This formula should return 'Middle' if between 25% and 75% of an opportunity has passed
  • This formula should return 'Late' if more than 75% of an opportunity has passed
  • This formula should reference a helper formula field, also on the Opportunity Object, with the type Percent and the name Percent Completed
  • Percent Completed should return the percentage of the time that has passed between an opportunity’s CreatedDate and CloseDate.

1) Create one custom 'Percent Completed' helper formula field on opportunity object of type percent and enter the below formula.

(TODAY() - DATEVALUE(CreatedDate))/(CloseDate - DATEVALUE(CreatedDate))

2) Create one custom 'Opportunity Progress' formula field on opportunity object of type text and enter the below formula.


IF( Percent_Completed__c <=25,"Early", 

IF(Percent_Completed__c <=75,"Middle", 

"Late"))
Troubleshoot a formula and fix a couple of errors.

The following formula, meant to return the last day of the current month, has a couple of errors in it: 

IF( MONTH( NOW() ) = 12,
  DATE( YEAR( NOW() ), 12, 31 ),
  DATE( YEAR( NOW() ), MONTH( NOW() ) + 1, 1) - 1

Create a new formula with the same label, name, and data type that successfully compiles.

  • The formula should be of Date type and on the Case object
  • The formula should have the name Last Day of Month and the resulting API name Last_Day_of_Month__c
  • The formula should return the last day of the current month.

1) Create one custom 'Last Day of Month' formula field on case object of type date and enter the below formula.


IF(

  MONTH( today() ) = 12,

  DATE( YEAR( today() ), 12, 31 ),
  DATE( YEAR( today() ), MONTH ( today() ) + 1, 1 ) - 1 
)

No comments:

Post a Comment

All Governor Limit

Number of SOQL queries: 100 Number of query rows: 50,000 Number of SOSL queries: 20 Number of DML statements: 150 Number of DML rows: 10,...