Sie sind auf Seite 1von 18

Salesforce Interview Preparation Toolkit

Formula and Validation Rules in SalesForce CRM

Description:
BISP is committed to provide BEST learning material to the beginners and advance learners. In the same series, we have prepared a complete end-to end Hands-on Beginners G ide !or Sales"orce. The doc ment !oc ses on some common interview # estions related to "orm las and $alidation % les. &oin o r pro!essional training program and learn !rom e'perts.

History:
Version Description Change 0.1 Initial Draft 0.1 $e%ie&'1 Author Chandra Prakash har!a A!it har!a Publish Date 10th Apr "01# 10th Apr "01#

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 1

Question : 1
SAP_Account_Id__c and Navison_Account_Id__c are two Text fields, Sell_to__c and Ship_to__c are two checkboxes. The rule should ensure that a record which has either SAP_Account_Id__c or Navison_Account_Id__c filled in or both!, can be saved onl" if either Sell_to__c and Ship_to__c or both! are checked. Solution :

#o to Setup $ Create $ Objects $ Select ob%ect na&e 'x( Sap Account!, then )o to down select *alidation rule +lick on New button, "ou can see below.

Then write here validation rule "ou can see below.

Note : If ou need !ot" c"ec# bo$ c"ec# use t"is Validation%

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page ,

-. IS/0AN1 SAP_Account_Id__c ! , IS/0AN1 Navison_Account_Id__c ! ,I2 Sell_to__c 3 false, true ,false! ,I2 ship_to__c 3 false, true ,false! !

Question : &
+reate a validation rule that when 4"_+heck__c is unchecked, the Text2ield1__c and Text2ield,__c should have no values. Solution :

/elow is validation .ule ..

Code : -.'M (C"ec#((c)) F*+S, OR' IS!+*N.' /e$tField1((c 0 - IS!+*N.' /e$tField&((c 0 0 0 0

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 5

Question 1 :
Validation rule for currenc wit" & decimal 2alues ,$ample : *alid( 1,.66, 1,.16, 1,.61, 1,.78 Not *alid( 1,, 1,.1, 1,.6,1,.,65 Solution :

NO/'R,3,4'5rice((c-6789:;<7%;=1>789:;=&>600

Question ? :
Appl" to for&ula to the field which depends on so&e other field. I created a picklist field which contains /-9, +lass:A, +lass:/, +lass:+. If an"one selected /-9 in that picklist field then auto&aticall" Ticket fare has to reflect as 166,if the" selected +lass:A then ;7 has to reflect and so on. Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page <

Code : IF'IS5IC.V*+' Seats(Cate@or ((c- A!o$A0-61886-IF'IS5IC.V*+'Seats(Cate@or ((c- AClass9 *A0-6BC6-IF'IS5IC.V*+'Seats(Cate@or ((c- AClass9 !A0-6C86-IF'IS5IC.V*+'Seats(Cate@or ((c-AClass9CA0-6&C6-6860000 Result :

Question C: Compare & c"ec#bo$es to complete a te$t field%


Need to co&pare the contents of , checkbox fields. If the" both are checked, I want the new field to displa" =>i)ital and Ph"sical=. If the di)ital checkbox field is checked, but the ph"sical one is not, then I want to displa" =>i)ital -nl"=. If the ph"sical checkbox field is checked but the di)ital one is not, then I want to displa" =Ph"sical -nl"=. If neither fields are checked, then I want to displa" =Neither=. Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 7

Validation Rule :

Code : IF( AND( Channel_Digital_Distribution__c == False, Channel_Physical_Fulfillment__c == False) , "Neither", IF( AND( Channel_Digital_Distribution__c == rue , Channel_Physical_Fulfillment__c == rue) , "Digital an! Physical", IF( Channel_Physical_Fulfillment__c == rue , "Physical "nly", IF(Channel_Digital_Distribution__c == rue , " Digital "nly" , "False") ) ) )

Question D : Calculate Case *@e e$cludin@ wee#ends%


+reate one for&ula field returns nu&ber! which will calculate +ase A)e In da"s! such that it will keep incre&entin) until case is closed. If the case is closed it will stop countin). This excludes weekends. Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 8

Formula :

Question B : Validation rules to 2alidate email address format%


Since it is a text field, there is possibilit" that user will enter wron) e&ail address for e.).( abc,ht.co& &issin) ?@?!. is there an" validation for&ula rule that can validate e&ail address for&at can share here.A Solution :

Code : www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page ;

NO/'R,3,4' ,mail(Id((c -67a9E*9F89:%(9;<G7a9E*9F;<%7a9E*9F;=&-?>600

Question H : +imit number of selections from multi9select pic#list%


There a wa" to restrict users to onl" pickin) 5 selections fro& a &ulti:select picklist that contains ,6 optionsA Solution H :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page B

Code : IF'INC+IJ,S'Multi(5ic#list((c- 6*60-1-80 < IF'INC+IJ,S' Multi(5ic#list((c- 6!60-1-80 < IF'INC+IJ,S' Multi(5ic#list((c- 6C60-1-80 < IF'INC+IJ,S' Multi(5ic#list((c- 6J60-1-80 < IF'INC+IJ,S' Multi(5ic#list((c- 6,60-1-80 K 1

Question : : Validation rule te$t field allows 7a9E;7*9F; and space bar%
+reate one custo& text Text61__c! field. This field allows characters Ca:DECA:FE and space bar onl". An" for&ula or validation rule or workflow rule. It not allows nu&eric?s C6:GE and special character. Solution : NO/'R,3,4'/e$t81((c- 6'7a9E*9F ;0L600

Question 18 : Number of da s between ,2ent and CloseJate%


+alculate how &an" da"s it takes fro& visitin) the custo&er until the opportunit" is closed. He use events onl" for these visits, so ever" account onl" has one event. Hhat I need to do is to cop" the date of this event either to an opportunit" or account to add another custo& field to calculate the da"s between start date I alread" cloned this field in the event to use it in for&ulas! and close date. Another proble& is, that +lose>ate is onl" >ate and not >ateTi&e like &" cloned Start>ate. An" chance to calculate it an"wa".A Solution : Iere Apex Tri))er +ode.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page G

Apex +lass ( Iere "ou can write apex test class.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 16

Question 11 : +ast modified date wor#flow rule%


+reated a custo& field on +ase ob%ect 0ast &odified b" owner dateJti&e. I also created a for&ula field and a workflow rule to insert date and ti&e whenever -nl" the +ase -wner &odif" the status field. Now i a& tr"in) to create another workflow rule that if +ase -wner doesn?t &odif" case status with in 5 da"s then it should send e&ail notification to &ana)er that the status of this case hasn?t been chan)ed b" case owner in last 5 da"s. Solution : 1. +reate a for&ula field J return t"pe checkbox on case.

,. +reate a workflow rule with entr" criteria( above checkbox is true : add wf rule : e&ail to send the notification

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 11

Question 1&: Create a formula field- w"ic" will be updated based on two ot"er fields%
In 0eads Pa)e, I want to have a Sales Score Text field for&ula field !, which needs to be updated b" first checkin) the ca&pai)n field is e&pt" or not and has to update the Sales Score field based on other +a&pai)n Score field Nu&ber field!. Solution :

Code : I2 IS/0AN1 +a&pai)n_2ield_Na&e((c0-Campai@n(Score(Field((c-6N*60

Question 11 : 2alidation rule field s"ould be null%


Iave a checkbox field +heckbox1__c and two text fields Text2ield1__c and Text2ield,__c this validation rule doesn?t work( I2 +heckbox1__c33 false, Text2ield1__c3 null KK Text2ield,__c3 null, Text2ield1__c3 null KK Text2ield,__c3 null!. Hant to create a validation rule that when +heckbox1__c is unchecked, the Text2ield1__c and Text2ield,__c should have no values. Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 1,

Code : AN> +heckbox1__c 33 2A0S' , N-T AN> IS/0AN1 Text2ield1__c ! , IS/0AN1 Text2ield,__c ! ! ! !

Question 1? : Mow can I split custom Customer Name te$t field into First Name and +ast Name%
He have +ontact us web,lead! for& on our co&pan" website. In that contact us for& we have asked onl" four fields Na&e, '&ail, Phone and State. Na&e field is feedin) custo& +usto&er Na&e field T"pe Text , siDe 3 ,77!, '&ail field is feedin) Standard '&ail field, Phone is feedin) Standard Phone field and State is feedin) Standard StateJProvince field in Sales2orce. I a& tr"in) to &ake a workflow field update that split +usto&er Na&e and feed 2irst na&e and 0ast na&e Standard fields Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 15

Formula For First Name:

Formula For +ast Name :

*fter Sa2e /"is Jata :

Question 1C : Formula Field to counts e2ents for a compan


+reatin) a for&ula that counts events for a co&pan". The hitch is : if the =&eetin) t"pe= field which is a custo& picklist! on the activit" record is =conference call= or =web &eetin)= : I do not want it to count it. I put to)ether the for&ula below : but it does not see& to be workin). An" help would be ver" appreciated. I2 AN> Activit"_T"pe__c 3 ='vent=, -. N-T ISPI+1*A0 4eetin)_T"pe__c, =+onference +all=!!, N-T ISPI+1*A0 4eetin)_T"pe__c, =Heb +onference=!!!! , 1, 6! Actiivt"_T"pe__+ is a text for&ula field that will either be ='vent= or =Task=.

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 1<

Solution :

Formula :

Code : I2 AN> Activit"_T"pe__c 3 ='vent=, N-T -. ISPI+1*A0 4eetin)_T"pe__c, =+onference +all=!, ISPI+1*A0 4eetin)_T"pe__c, =Heb +onference=!!!!, 1, 6!

Question 1D : Calculate wee# of t"e mont"%


Hhat I actuall" want is suppose if I have 7, records created with the start date and end dates like.. 1st... 1J1J,61< to BJ1J,61<. ,nd ... BJ1J,61< to 17J1J,61< and so on. so I want to calculate that what is the nu&ber of week like.... 1st week , ,nd week and so on..

Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 17

Formula :

Code : +'I0IN#

Start_>ate__c : >AT' L'A. Start_>ate__c !, 4onth Start_>ate__c !, 1! M 1! J ;!

Question 1B : Remo2e w"ite spaces between two words in formula%


He currentl" have a workflow that creates a =du&&"= e&ail address when an e&ail address is not provided in a lead or contact record. The business reNuire&ent is for the e&ail address to be 2irstNa&e. 0astNa&e@+o&pan".no&ail. The proble& we?re runnin) into is that the e&ail fields do not like an" spaces in the e&ail address, which is a proble& for co&panies with &ultiple words in their na&e.. i.e. So&e /ur)er +orp. +ontact na&es also cause the sa&e issue. The workflow uses a si&ple for&ula to set the value( 2irstNa&e M=.=M 0astNa&e M=@=M +o&pan" M=.=M =no&ail= Is there a wa" to re&ove all white spaces in a concatenation for&ulaA Solution :

Formula :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 18

Code : SO/STITOT' 2irstNa&e__c , = =, ==!M=.=M SO/STITOT' 0astNa&e__c , = =, ==!M=@=M SO/STITOT' +o&pan"__c , = =, ==! M=.=M =no&ail=

Question 1H: Nritin@ comple$ 2alidation rule%


If 'sti&ated value 3 null and Status picklist value 3faxed and date fax sent is )reater than 11J1J,615 here?s what i wrote so far, but i see& to have an error so&ewhere as when i tr" to save a lead with the first , criterias but date fax sent older than 11J1J,615 i still )et validated and cannot save lead. Solution :

Code : AN> IS/0AN1 'sti&ated_*alue__c ! , ISPI+1*A0 Status__c , =2axed=!, >ate_2ax_Sent__c $ >AT' ,61<,,,11!! ! www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1;

Question 1: : Contact Roles ReOuired Conditional Rules%


Started usin) the +ontact .oles .eNuired for app, and I?ve setup the condition rule to include ( AN> +reated>ate PN-H !!,N-T Pri&ar"_+ontact_Assi)ned__c!! but this is creatin) havoc on our tea& since this rule forces "ou to add a pri&ar" contact role to all opportunities, even those fro& 7 "ears a)o. So now I?& tr"in) to create a conditional rule that will reNuire a pri&ar" contact role for opportunities created as of 1J1J,615. Solution :

www.bispsolutions.com

www.bisptrainigs.com

www.hyperionguru.com

Page 1B

Das könnte Ihnen auch gefallen