Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

May 30, 2012

Update Record From Formula Field

Recently an interesting implementation forced me to write this post, and may be many of you are already aware of this. There is a related list where I need to show a formula field, and on click of that field I need to change the status of that record.

Say case is related to account, and they are displayed in a related list on account. Now I want to change the status of any case which is related to an account. One way is to click on the case "edit", change the status and save it. I don't want to do this as it takes time and more button clicks. Another way is to provide a formula field as a hyperlink, and when that link is clicked status should be changed.

So for this create a formula field on Case ("UpdateStatus" for the reference) which will be a hyperlink and it will execute an visualforce page like this :

HYPERLINK("/apex/UpdateStatus?RecId=" + Id ,"Click To Change Status","_top")


Now add this formula field in case related list on account page layout, like this :



Now it's time to write a Visualforce page, so here is the code :


    
    
    
    



I know this is not the best approach to go with, and am open for any other solutions or findings.