+ Start a Discussion
Anil DuttAnil Dutt 

Formula for Picklist

Hi,

 

I have a Picklist with following values

 

Virgin Australia
Virgin Atlantic
Virgin America
US AIR
United Airlines    

 

I want to create a formula field so when any value selected it will give a link

 

Virgin Australia         http://www.virginaustralia.com/Personal/Bookings/Managebookings/index.htm     
Virgin Atlantic         https://www.virgin-atlantic.com/en/us/manageyourflights/updatebooking/index.jsp     
Virgin America              http://www.virginamerica.com/view-itinerary.html     
US AIR                     http://reservations.usairways.com/Default.aspx     
United Airlines         http://www.united.com/page/genericpage/0,,52172,00.html?navSource=dropDown&linkTitle=itineraries

 

Please help, how tyo achieve this?

 

Thanks,

Best Answer chosen by Admin (Salesforce Developers) 
Shukla_AnkitShukla_Ankit

Hi,

 

For this  issue you have to write apex trigger with befor insert and before update action on required object.

 

Thanks...

All Answers

Shukla_AnkitShukla_Ankit

Hello,

 

Here is a formula for your requirement

 

IF(ISPICKVAL(Picklist_Field_name, 'Virgin Australia') , 
HYPERLINK("http://www.virginaustralia.com/Personal/Bookings/Managebookings/index.htm", "  http://www.virginaustralia.com/Personal/Bookings/Managebookings/index.htm") ,


IF(ISPICKVAL(Picklist_Field_name, 'Virgin Atlantic') , 
HYPERLINK("https://www.virgin-atlantic.com/en/us/manageyourflights/updatebooking/index.jsp", "https://www.virgin-atlantic.com/en/us/manageyourflights/updatebooking/index.jsp") ,

 

IF(ISPICKVAL(Picklist_Field_name, 'Virgin America') , 
HYPERLINK("http://www.virginamerica.com/view-itinerary.html ", "http://www.virginamerica.com/view-itinerary.html ") ,

 

IF(ISPICKVAL(Picklist_Field_name, 'US AIR') , 
HYPERLINK("http://reservations.usairways.com/Default.aspx ", "http://reservations.usairways.com/Default.aspx ") ,

 

IF(ISPICKVAL(Picklist_Field_name, 'United Airlines') , 
HYPERLINK("http://www.united.com/page/genericpage/0,,52172,00.html?navSource=dropDown&linkTitle=itineraries ", "http://www.united.com/page/genericpage/0,,52172,00.html?navSource=dropDown&linkTitle=itineraries ") , '' )))))

 

If this solution solve your problum please mark as solution.

 

Thanks

Anil DuttAnil Dutt

@Shukla_Ankit

 

thanks for your reply, its working but i have another problem

 

i have a very large number of picklist values

 

CASE(Airline__c , "Virgin Australia",HYPERLINK("http://www.virginaustralia.com/Personal/Bookings/Managebookings/index.htm","Virgin Australia"),
"Virgin Atlantic",HYPERLINK("https://www.virgin-atlantic.com/en/us/manageyourflights/updatebooking/index.jsp","Virgin Atlantic"),
"Virgin America",HYPERLINK("http://www.virginamerica.com/view-itinerary.html","Virgin Australia"),
"US AIR",HYPERLINK("http://reservations.usairways.com/Default.aspx","Virgin America"),
"United Airlines",HYPERLINK("http://www.united.com/page/genericpage/0,,52172,00.html?navSource=dropDown&linkTitle=itineraries","United Airlines"),
"Turkish Air",HYPERLINK("http://www4.thy.com/mybookings/reservations.tk?target=view&lang=en","Turkish Air"),
"Turkish Air",HYPERLINK("http://www.thaiair.com/AWR_PREM/view-trip.jsp","Turkish Air"),
"Swiss Airlines",HYPERLINK("http://www.swiss.com/web/EN/Pages/index.aspx?Country=US","Swiss Airlines"),
"Southwest Airlines",HYPERLINK("https://www.southwest.com/flight/lookup-air-reservation.html?int=GSUBNAV-AIR-RETRIEVE&forceNe...","Southwest Airlines"),
"South African",HYPERLINK("https://www.flysaa.com/Journeys/reservation/searchpnr.action?nameSpace=reservation","South African"),
"Singapore Airlines",HYPERLINK("https://www.singaporeair.com/manageBooking-flow.form?execution=e1s1","Singapore Airlines"),
"QATAR AIRWAYS",HYPERLINK("http://www.qatarairways.com/us/en/homepage.page","QATAR AIRWAYS"),
"Qantas Airlines",HYPERLINK("http://www.qantas.com.au/travel/airlines/your-booking/global/en","Qantas Airlines"),
"Malaysia",HYPERLINK("https://book.malaysiaairlines.com/itd/itd/lang/en/reservations","Malaysia"),
"Lufthansa",HYPERLINK("http://www.lufthansa.com/online/portal/lh/us/my_account/my_bookings","Lufthansa"),
"KLM - Royal Dutch Airlines",HYPERLINK("http://www.klm.com/travel/us_en/index.htm#tab=db_mmb","KLM - Royal Dutch Airlines"),
"Japan Air",HYPERLINK("http://www.5971.jal.co.jp/eng/SearchReservation.do","Japan Air"),
"Etihad Airlines",HYPERLINK("http://www.etihadairways.com/sites/etihad/_layouts/etihad/obe/RetrieveBooking.aspx","Etihad Airlines"),
"Emirates",HYPERLINK("https://fly.emirates.com/MYB/MMBLogin.aspx","Emirates"),
"Delta Airlines",HYPERLINK("http://www.delta.com/","Delta Airlines"),
"Copa Airlines",HYPERLINK("http://www.copaair.com/sites/US/EN/Pages/homepage.aspx","Copa Airlines"),
"Continental Airlines",HYPERLINK("http://www.continental.com/web/en-US/apps/reservation/default.aspx","Continental Airlines"),
"Cathay Pacific",HYPERLINK("http://www.cathaypacific.com/cpa/en_US/manageyourtrip/managemybooking?loginType=nonmember","Cathay Pacific"),
"")

 

so it give following error

 

Error: Compiled formula is too big to execute (5,185 characters). Maximum size is 5,000 characters

 

Any idea?

Shukla_AnkitShukla_Ankit

Hi,

 

For this  issue you have to write apex trigger with befor insert and before update action on required object.

 

Thanks...

This was selected as the best answer
Anil DuttAnil Dutt

I need this formula in an Email Template body

 

what will trigger do?

Anil DuttAnil Dutt

Thanks @Shukla_Ankit,

i got your suggestion and created an extra field in object and using befor insert and before update trigger on object creation/updation , updated new filed with corresponding link


Thanks alot......