6

How to generate a confirmation token to delete a related list record?

When we delete a related list record it takes 4 parameters -

1) id - Record id

2) delID= Related list record id

3) retURL

4) _CONFIRMATIONTOKEN

So how can we generate this _CONFIRMATIONTOKEN?

thanks in advance

  • Are you attempting this in Apex or another API? – Matt K Jun 25 '13 at 18:17
13

If you are in Visualforce, you can use the URLFOR() function in conjunction with the $Action global variable to generate this URL. The URLFOR function will automatically add the _CONFIRMATIONTOKEN to the end of your URL.

<apex:outputLink value="{!URLFOR($Action.OpportunityTeamMember.Delete,member.Id)}">
    <apex:outputText value="Delete"/>
</apex:outputLink>

This will generate URL's of the form:

https://<Instance>.salesforce.com/setup/own/deleteredirect.jsp?id=<Opportunity Id>&delID=<Opportunity Team Member Id>&retURL=%2F00Q%2Fo&_CONFIRMATIONTOKEN=<ConfirmationToken>

Here is a sample Visualforce Page, called 'OpportunityTest', that shows you the Team Members for an Opportunity, and allows you to Delete them using the above strategy. I have also added in a 'retURL' parameter to the Output Link, which takes you back to the OpportunityTest page:

<apex:page standardController="Opportunity">

<apex:sectionHeader title="{!Opportunity.Name}"/>

<apex:pageBlock title="Team Members">
<apex:pageBlockTable value="{!Opportunity.OpportunityTeamMembers}" var="member">
    <apex:column headerValue="Action">
        <apex:outputLink value="{!URLFOR(
                $Action.OpportunityTeamMember.Delete,
                member.Id,
                [retURL='/apex/OpportunityTest?id='&opportunity.Id]
         )}">
            <apex:outputText value="Delete"/>
        </apex:outputLink>
    </apex:column>
    <apex:column value="{!member.User.Name}"/>            
    <apex:column value="{!member.TeamMemberRole}"/>
</apex:pageBlockTable>
</apex:pageBlock>

</apex:page>

enter image description here

| improve this answer | |
  • I used custom logic to iterate "Opportunity Team" list on opportunity. Now i want, when user clicks on "Del" link that record should be deleted and for that i need "confirmation token". so how can i achieve this? plz explain – Pramod Kumar Jun 26 '13 at 3:21
  • what would be $Action string to delete opp team record? – Pramod Kumar Jun 26 '13 at 3:43
  • Pramod, i have updated my answer above with a better example, but the $Action is $Action.OpportunityTeamMember.Delete. – zachelrath Jun 26 '13 at 14:17
0

I've seen this on the force.com discussions... here: Token for URL to delete a record?

Hope this gets you where you are going!

| improve this answer | |
  • That post just links to another post which is a discussion of how to build a button that is similar to the standard delete button (e.g. a javascript confirm). It doesn't seem to be related to confirmation tokens at all. – ca_peterson Jun 25 '13 at 20:02
  • I'm just new here, and trying to help... this q had been open for hours with no responses, so thought a little was better than nothing. – dacology Jun 25 '13 at 20:08
  • @dacology, thanks for getting involved! In this case, a comment would have probably been a better way to give some feedback. Since you are new, you may not have had the permission to comment yet, but now that you have some reputation, you should be able to. Always good to see new faces on the site! – Daniel Hoechst Jun 26 '13 at 14:46
  • Yes, thanks. I am beginning to understand and appreciate how it all works now. – dacology Jun 26 '13 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.