Skip to main content
Hi All,

 

I have a custom button (custom URL behind it) that triggers a record to be mapped to and create another record on a different object (Object Converter App)

 

Can this button be triggered via a WFR?  Essentially, can the custom URL be executed via a WFR?

 

Thanks!
8 answers
  1. Nov 5, 2013, 8:10 PM
    Hey Steve,

     

    This is definitely possible via an Apex Trigger. But it is not with just an Apex Trigger but also with a Visualforce Page. So if you are to implement an Apex Trigger, I would suggest you to have some intro to the basic things like: Loging to Sandbox , Implementing your Trigger (not write the Code but put them in place), Running Your Apex Tests , Moving them to the Production via Changesets  etc.

     

    Implementation :

     

    There will be two fields on the Opportunity - URL and IsVisited.

     

    The URL will carry the link to which the User should actually be redirected to when an Opportunity is set to Closed Won or Closed Lost . The URL field will intially be empty . When a User updates the Stage to ClosedWon / ClosedLost , an Apex Trigger populates the URL with the link .

     

    The IsVisited is a Checkbox that identifies whether a redirection to the URL was done in the past or not. If IsVisited is checked , then no redirection takes place otherwise, the IsVisited will be updated to checked and then the redirection would happen. So this is a one time process( redirection ).

     

    So lemme brief if in case you or someone else at a later point wanted to do this and then......

     

    1. So at first we have to create two fields on the Opportunity

    • URL

      • ​Field Name : URL

      • Field API Name : URL__c

      • Type : TEXT(255)

    • IsVisited

      • ​ Field Name : IsVisited

      • Field API Name : IsVisited__c

      • Type : Checkbox

    Note

    : You need not put them on the Page Layout since these are for the Internal Usage.

     

    2. Now let us build the Apex Trigger. Go to Setup | Customize | Opportunities | Triggers. So the code will be: https://gist.github.com/anonymous/8e8e9017ceb4425cf043

     

     

    Hey Steve, This is definitely possible via an Apex Trigger. But it is not with just an Apex Trigger but also with a Visualforce Page.

     

     

     

    3. Now, the Visualforce Page that will do the redirection. So here you go: https://gist.github.com/anonymous/1461a010130927245145

     

    User-added image

     

    4. Well, we are nearing to the end of the story!. We now have to drag the Visualforce Page on to the Page Layout like as below:

     

    User-added image

     

    Save it. Now go to any Opportunity record, Update the Stage to ClosedWon and you would be redirected to the link in the URL field that gets populated as a result of the Trigger! Come back to the same Opportunity record and you would notice, that it will not redirect any more and the IsVisited will be checked.

     

    This just shows how extensible is the Platform! Its all possible :)

     

    Happy Salesforcin ,

     

    Deepak
0/9000