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
Arun KArun K 

EnhancedList------I want to remove records from sobject using enhancedlist

I want to remove records from sobject using enhancedlist.

 

iam looking for that functionality.Anyone who can help in this regard would be great

AmitSahuAmitSahu
What do you mean by removing records.. delete from object or just from list
SFDC-SDSFDC-SD

You cannot do that using out-of-the-box functionality.

 

Arun KArun K

Yes,

 

I want to remove records from one object from enhancedlist and add it to other object..

 

yes,I will do that

Arun KArun K

thanks for the reply

 

then what should i do to make that custom functionality.

Please help me in this regard.

 

 

SFDC-SDSFDC-SD

Create a visualforce  and implement the list view/edit/delete functionality on that. Implement search criteria so that you can filter and delete all records that satisfy your conditions. 

Arun KArun K

 

I managed to create the visualforce and apex class,  and managed to make a list button

 

But I stuck in remove the seleted records... 

 

I think I need add some functionality in apex class for the list button

 

 

 

My visualforce page is------

 

<apex:page controller="view">
 <h1>{!$User.FirstName} </h1>


<table><tr><td>
<apex:pageblock >

<apex:enhancedList type="custom object" height="750" rowsPerPage="200">
<apex:facet name="header">
&nbsp;
</apex:facet>
</apex:enhancedList>
<apex:form >
<apex:commandButton value="Remove from custom object" action="{!remove}" />
</apex:form>
</apex:pageblock>
</td>
<td>
<h1>This map shows the locations of Accounts who are in <b>{!$User.FirstName}</b> Location.</h1>
<apex:includeScript value="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=salesforce.com"/>





</td>
</tr></table>
<h1><apex:outputText value="{!count}"/></h1>
<b/>

<apex:pageBlock >
<apex:enhancedList listid="xxxxxxxxxxx" height="400" customizable="false"/>
<h1><apex:outputText value="{!accountcount}"/> </h1>
<apex:form >
<apex:commandButton value="custom object" action="{!add}" />
</apex:form>
</apex:pageBlock>

</apex:page>

 

 

 

My apex class is------

 

public with sharing class view {

public view() {

}


public view(ApexPages.StandardController controller) {

}


public String getUser() {
return null;
}


public PageReference add() {
return null;
}


public integer getAccountcount() {
return [Select count() from Account ];
}


public integer getCount() {
return [Select count() from call_plan__c ];
}


public PageReference remove() {
return null;
}

}

 

 

 

Please help in this regard.

 

 

 

SFDC-SDSFDC-SD
// Please use the some logic as given below... you need to have a record and a checkbox to do mass deletes
// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose
//instances are collections of other objects. In this example a wrapper class contains both the standard salesforce 
// object Contact and a Boolean value

public class accList{
public Account objacc {get; set;}
public Boolean selected {get; set;}

//This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property.
// We also set the selected value to false
  public acclist(Account a) {
    objacc = a;
    selected = false;
  }
}

 

Arun KArun K

Thanks for that,  I added wrapper class in my class

 

I selected few records and when I clciked "remove from object" button which is in visualforce page records are not removing.

 

should I need to add few customization??

 

 

 

 

 

Arun KArun K

this is the exact code which is in org

 

Vf page------

 

<apex:page controller="view">
<!--<head>
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-1.4.2.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jQuery, '/js/jquery-ui-1.8.6.custom.min.js')}" />
<apex:stylesheet value="{!URLFOR($Resource.jQuery, '/css/ui-lightness/jquery-ui-1.8.6.custom.css')}" />
<script>
$("div.listViewport div.x-panel-body a").live("click", function(){
var sURL = $(this).attr("href");
if (sURL.indexOf("?") != -1) {
sURL += "&isdtp=mn";
} else {
sURL += "?isdtp=mn";
}
window.open(sURL, "Manage", "width=1000,height=700,menubar=1,resizable=1,scrollbars=1,status=1,location=1");
return false;
});
</script>
</head> -->






<h1>{!$User.FirstName} Call Plan</h1>


<table><tr><td>
<apex:pageblock >

<apex:enhancedList type="call_plan__c" height="750" rowsPerPage="200" customizable="false">
<apex:facet name="header">
&nbsp;
</apex:facet>
</apex:enhancedList>
<apex:form >
<apex:commandButton value="Remove from Call Plan" action="{!remove}" />
</apex:form>
</apex:pageblock>
</td>
<td>

This map shows the locations of Accounts who are in <b>{!$User.FirstName}'s</b> Location.






</td>
</tr></table>
<h1><apex:outputText value="{!count}"/></h1>
<b/>

<apex:pageBlock >
<apex:enhancedList type="call_plan__c" height="400" rowsPerPage="200" customizable="false"/>
<h1><apex:outputText value="{!accountcount}"/> </h1>
<apex:form >
<apex:commandButton value="Add to Call Plan" action="{!add}" />
</apex:form>
</apex:pageBlock>

</apex:page>

 

 

 

My apex calss after adding ur wrapper class---

 

public with sharing class view {

public view() {

}
public class accList{
public Account objacc {get; set;}
public Boolean selected {get; set;}

//This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property.
// We also set the selected value to false
public acclist(Account a) {
objacc = a;
selected = false;
}
}

public view(ApexPages.StandardController controller) {

}


public String getUser() {
return null;
}


public PageReference add() {
return null;
}


public integer getAccountcount() {
return [Select count() from Account ];
}


public integer getCount() {
return [Select count() from call_plan__c ];
}


public PageReference remove() {
return null;
}

}

 

 

Please add customization that I need to do..??

If u want I can send my look and feel of my vf page

 

 

 

 

 

SFDC-SDSFDC-SD

Delete using the logic below

	public List<account> Listacc{get; set;}        
	public PageReference remove() {	

	        // Get all the accounts that are selected using CheckBox
        	List<account> selected_accounts = new List<account>();        

	        for(account objacc : getListacc()) {            
		   if(objacc.selected == true) {            
	      	      objacc.selected =false;                
   	      	      selected_accounts.add(objacc.objlr );            
            	   }        
		}                
	// Now we have our list of selected contacts to delete; Get their Ids and delete    

		set<Id> accIds = new Set<Id>;
		for(account a : selectedacc) {            
    	    	    accIds.add(a.Id);                                    
		}        
		delete from account where Id IN :accIds;
		return null;    
	}

 

Arun KArun K

Hi,

I need a requirement which calculates no of records that are shown in enhancedlist(records are shown 50 out of 120) and according to that horizontalbar should be displayed.
If i remove records from enhancedlist, the horizontalbar should update

Can I know to do this.??

Arun KArun K

Hi,

I need a requirement which calculates no of records that are shown in enhancedlist(records are shown 50 out of 120) and according to that horizontalbar should be displayed.
If i remove records from enhancedlist, the horizontalbar should update

Can I know to do this.??

ameghamegh

i want to hide listbuttons from listviewport.How is it possible?any idea?

Arun KArun K

Goto

 

setup--> respective object->search layout--> object name list view -->> Uncheck the buttons that are not required

 

thanks