Tuesday, November 15, 2016

Open a VF Page related to a record from a List View/Related List, or send out email without actually navigating to the Record

Use Case
If we need to open a VF Page related to a record from a List View/Related List, or we would want to send out email without actually navigating to the Record.

Solution

As previously mentioned, we will be using the HYPERLINK function of Formula Fields. Using this we will be invoking JavaScript.

In a Formula field, choose HYPERLINK function, return type as Text and write this formula:
HYPERLINK ("javascript:alert('Bingo!');","Click Here","_top")
Now, click on the Link and you will see an alert, BINGO!

A bit complex formula (Calling a VF Page) will be like:
HYPERLINK ("javascript:window.open('https://c.cs41.visual.force.com/apex/VF_SearchAssignCI?uid=" & id & "','','width=800, height=500, top=200, left=200');","Click Here","_top")

Similarly we can also use mailto URI scheme in order to invoke users’ desktop email client and also prepopulate values in the sameJ. A formula for that would be like (Example is written on Contact Object):
HYPERLINK ('mailto:'+ Email +'?subject=Contact %23'+LastName+' (Ref:CON:'+LastName+') &cc=test@test.org&body=%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A-----------%0D%0A(Ref:CON:'+LastName+')%0D%0AImportant: Please use %22Reply All%22 button when responding to this email.%0D%0APlease refrain from changing the subject line while replying.',Email,'_parent')



No comments:

Post a Comment