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.

5 comments:

  1. No need for code! Just use the URL hack: http://screencast.com/t/iKgmrEsiad

    The idea is the same, create a URL, but now just merge in the proper IDs, use the standard {!field name here} for the related record. But what you do is use the standard 'edit' URL of the object and insert your values as shown in the screencast.

    ReplyDelete
  2. @Pete: The URL hacking sometimes does not work. Salesforce then just returns some strange "invalid session" error. - But in those Orgs where it works, its of course easier then setting up a page.

    @Ankit: Some would say you would need to create a page + controller to be safe, but I would go for the much easier ajax toolkit implementation as well ;)
    Good posting!

    ReplyDelete
  3. Hi,
    My requirement is here.
    "http://salesforce.stackexchange.com/questions/7855/hyperlink-in-helptext-which-is-bought-from-xml"
    Any Ideas on it

    ReplyDelete
  4. I feel the article is very interesting. I also appreciate your writings. Please look at my articles dentist baulkham hills Thank you.

    ReplyDelete