2

I have got an module to work on. I am having a button which sends some information to contacts on opportunity through mail. This information mainly concist a link which should be a url to a visual force page and include a token that should expire in 24 hours. On click of this URL user should see the related information on oppty. If user hits the link after 24 hrs it should not be valid.

I am not understanding how this URL can be generated and processed. Mainly how to handle link visibility.

Thank in advance, Best Regards

2 Answers 2

5

Lets look at this from the ground up. You'll need to store the fact that the link is expired somewhere, preferably where your end user can't get to it.

If your link is pulling all of its information from a single object and sending it to one or multiple people at the same time, consider a custom date/time field on Opportunity to store the expiration date. I'm not going to go in to how to set that field.

The links you send to your contacts should all reference the same Visualforce page, but they should have a URL parameter in them that references the object you want them to see information from:

http://instance.salesforce.com/apex/YourPage?id=opportunityId

If you're sending the link to the information on this object to multiple people at multiple different times, that complicates it.

To use that field, in your visualforce page you'll want to do something like this:

<apex:page action="{!checkExpiration}" controller="{!pageController}"/>

That action runs on page load, and inside the controller you'll have a function that might look like this.

public pageReference checkExpiration() {
  if(myObject.linkExpiration > System.now()) {
    //send your user to a page indicating the link is expired
    return new PageReference('/apex/LinkExpired');
  } else {
    return null;
  }
}
1

If you are sending the link to external contacts, I would consider using the Crypto class to encrypt the contents of the link. Adding to the previous suggestion, you could include the custom datetime value in the encrypted link as a parameter, and then have your controller decrypt the link, read the datetime value, and decide if it has expired...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .