function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VK86VK86 

Delete option for Partner Portal users

Hi,

 

I am aware that Partner Portal users do not have access to delete records of standard objects.

 

Wondering if we can have a custom button on Contacts object which will force delete that record on button click?

 

Thanks,

VK

Shashikant SharmaShashikant Sharma

I doubt this will work if you use native page layout and detail button. But What I can suggest to you is to create a VFP , StandardController="Contact"  and extention="ControllerClass" , Open this page on on click of this button and pass id of contact , You can use exeute JavaScript on button and use location.href=

 

This page should have a page level action to invoke controller method , which should delete the record from controller. Make the controller as  without sharing class.

Ankit AroraAnkit Arora

Here is code :

 

APEX 

 

public without sharing class DeleteContactFromSite
{
    public PageReference DeleteCon()
    {
        List<Contact> conLst = [select id from contact where id=: '00390000006jDat'] ;
        delete conLst[0] ;
        return null ;
    }
}

Hard code Id is just for testing. You can change the logic of getting records according to your need. 

 

VFP

 

<apex:page controller="DeleteContactFromSite">
<apex:form>
    <apex:pageBlock>
        <apex:pageMessages/>
        <apex:pageBlockButtons>
            <apex:commandButton value="Delete" action="{!DeleteCon}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

VK86VK86

Thanks Ankit, I will try this.

 

thanks,

VK

Ankit AroraAnkit Arora

Let me know if it work for you.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

VK86VK86

Hey Ankit,

 

I used the following on the Contact object. Here I am using a button which will execute a script just to change the Contact.Title to "Delete" and an admin will later review and do a perform a mass delete.

 

Got this from an AppExchange package.

 

/* This code allows the javascript to access the API and push data into the Org.*/ 
{!requireScript("/soap/ajax/10.0/connection.js")}; 
sforce.connection.session = "{!$Api.Session_ID}"; 
function updateContact( ) 
{ 
try 
{ 
var c = new sforce.SObject("Contact"); 
c.Id = "{!Contact.Id}"; 
c.LastName = c.LastName; 
c.Title = "Delete"; 
var result = sforce.connection.update([c]); 
if (result[0].getBoolean("success") == false ) 
{ 
alert(result[0].errors.message); 
return; 
} 
window.top.location.href="https://na8.salesforce.com/003?fcf=00BC00000086bCn"; 
} 
catch (e) 
{ 
alert(e); 
}
}
updateContact();

 

Hope this helps others with similar requirements.

 

Thanks,

VK