• #34983
     Anjali #8
    Forcetalks

    How to set expire a link after one time click in Salesforce

    How to set expire a link after one time click in Salesforce?

    Note: I want to use only links no button.

    #35059
    Forcetalks

    Hi,

    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;
    }
    }

    Thanks.

     

    #35088
    Salesforce | Parul Parul #2
    Forcetalks

    Hi

    In your html:

    <a href=”#” id=”myButton” title=””>Click Me!</a>
    In your js:

    (function(){
    var click_counter = 0;
    $(‘#myButton’).on(‘click’, function(event){
    event.preventDefault();
    var el = jQuery(this);
    click_counter += 1;
    if (!el.hasClass(‘inactive’)){
    // should be activated
    alert(‘You have clicked the link ‘ + click_counter + ‘ once , And this will be disabled’);
    };
    if (click_counter >= 1){
    // deactivate
    el.addClass(‘inactive’);
    };
    });
    })();
    And to indicate your button has been clicked , add this class to your CSS

    a.inactive {
    color: gray;
    text-decoration: line-through;
    }

    Hope this helps!

     

    Thanks

    #35389
    Salesforce | shariq shariq #1
    Forcetalks

    Hi,

    You need to use standard class JwtToken which generates token encoded from sobject field’s values and append that token in URL. This class gives the functionality to expire the token within some time limit or immediate depend upon youe logic.

    Hope this helps.

Viewing 4 posts - 1 through 4 (of 4 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?