Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

Embed Size (px)

Citation preview

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    1/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 Gide !or

    Sales"orce. The docment !ocses on some common interview #estions related to "ormlas

    and $alidation %les. &oin or pro!essional training program and learn !rom e'perts.

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

    www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    2/18

    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 Newbutton, "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

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    3/18

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    4/18

    Question :

    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;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

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    5/18

    Code :

    IF'IS5IC.V*+' Seats(Cate@or((c- A!o$A0-61886-IF'IS5IC.V*+'Seats(Cate@or((c- AClass9

    *A0-6B6-IF'IS5IC.V*+'Seats(Cate@or((c- AClass9

    !A0-686-IF'IS5IC.V*+'Seats(Cate@or((c-AClass9CA0-6&6-6860000

    Result :

    Question : 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

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    6/18

    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

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    7/18

    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.).(

    abcht.co& &issin) ?@?!. is there an" validation for&ula rule that can validate e&ail address for&at

    can share here.

    Solution :

    Code :

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

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    8/18

    NO/'R,3,4' ,mail(Id((c -67a9E*989%(9;

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    9/18

    Code :

    IF'INC+J,S'Multi(5ic#list((c- 6*60-1-80 IS/0AN Text2ield1__c ! , IS/0AN Text2ield__c ! ! ! !

    Question 1? : ow can I split custom Customer Name te$t field into First Name and+ast Name%

    He have +ontact us weblead! for& on our co&pan" website. In that contact us for& we haveasked 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

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    14/18

    Formula For First Name:

    Formula For +ast Name :

    *fter Sa2e /"is Jata :

    Question 1 : 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+*A04eetin)_T"pe__c, =+onference

    +all=!!, N-TISPI+*A04eetin)_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

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    15/18

    Solution :

    Formula :

    Code :

    I2 AN>Activit"_T"pe__c 3 ='vent=, N-T-ISPI+*A04eetin)_T"pe__c, =+onference +all=!,

    ISPI+*A04eetin)_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... 1J1J61< to BJ1J61

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    16/18

    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 reuire&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&ula

    Solution :

    Formula :

    www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 18

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/
  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    17/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: ritin@ comple$ 2alidation rule%

    If 'sti&ated value 3 null

    and Status picklist value 3faxed

    and date fax sent is )reater than 11J1J615here?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 11J1J615 i still )et validated and cannot save lead.

    Solution :

    Code :

    AN> IS/0AN 'sti&ated_*alue__c ! ,

    ISPI+*A0 Status__c , =2axed=!,

    >ate_2ax_Sent__c $ >AT'61

  • 8/13/2019 Salesforce Interview Preparation Toolkit Formula and Validation Rules in SalesForce

    18/18

    Question 1 : Contact Roles Reuired Conditional Rules%

    Started usin) the +ontact oles euired for app, and I?ve setup the condition rule to include ( AN>

    +reated>ate N-H!!,N-TPri&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 reuire a pri&ar" contact role for

    opportunities created as of 1J1J615.Solution :

    www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1B

    http://www.bispsolutions.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/http://www.bispsolutions.com/http://www.bisptrainigs.com/http://www.hyperionguru.com/