You need to sign in to do that
Don't have an account?
salesforce@14
how to add rows and remove rows in filter condition in VF Page.
Hi,
I pasted my code below. Help me to resolve my issue.
public void addrow()
{
rowlist = new List<Sobject>();
totalRecords=0;
sno = value.size();
system.debug('@@@@@@@@@@@@@'+sno);
for(Sobject s:val4)
{
wrapperclass wr = new wrapperclass('s.Email','s.Name',false,s.id,sno);
value.add(wr);
}
system.debug('$$$$$$$$$$$$$$$'+value);
}
Thanks.
I pasted my code below. Help me to resolve my issue.
public void addrow()
{
rowlist = new List<Sobject>();
totalRecords=0;
sno = value.size();
system.debug('@@@@@@@@@@@@@'+sno);
for(Sobject s:val4)
{
wrapperclass wr = new wrapperclass('s.Email','s.Name',false,s.id,sno);
value.add(wr);
}
system.debug('$$$$$$$$$$$$$$$'+value);
}
Thanks.
Please refer below link for more details
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000963NIAQ
Please check and let me know if you need any help
Thanks
Sandeep
I tried that code but its not working. can you give me someother way based on my code
Thanks
My Code:
Darked part is the issue area.
public class AllUserList
{
public list<SelectOption> selectedobject { get; set; }
public String objectName { get; set; }
public list<SelectOption> fieldsName {get;set;}
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Map<string,EmailTemplate> alltemplate;
Map<string,string> FieldType = new Map<string,string>();
Map<string,string> fieldTypes=new Map<string,string>();
public list<SelectOption> open{get;set;}
public list<selectoption> templates{get;set;}
public list<wrapperclass> value{get;set;}
public list<Sobject> rowlist{get;set;}
// Public list<Wrapper> wrap{get;set;}
Public List<sobject> val4{get;set;}
Public List<Contact> conList = new List<Contact>();
public string templatename{get;set;}
public Integer totalRecords;
public Integer sno=0;
public string templateid{get;set;}
Public string FieldName{get;set;}
public string query{get;set;}
public string Fname1{get;set;}
public string Operator1{get;set;}
public string Value1{get;set;}
public void search()
{
string whereQuery='select id,Name,Email from ObjectName';
string whereclause ='where';
if(Fname1!='' && Fname1!=null && Operator1!='' && Operator1!=null && Value1!='' && Value1!=null)
{
whereQuery=whereQuery+retwhereQuery(Fname1,Operator1,Value1)+' and ';
}
if(objectName=='Contact')
{
whereQuery = ' select id,Email,Name' + ' from ' + objectName + ' where ' + retwhereQuery(Fname1,Operator1,Value1);
}
else
if(objectName=='Lead')
{
whereQuery = ' select id,Email,Name' + ' from ' + objectName + ' where ' + retwhereQuery(Fname1,Operator1,Value1);
}
else
if(objectName=='User')
{
whereQuery = ' select id,Email,Name' + ' from ' + objectName + ' where ' + retwhereQuery(Fname1,Operator1,Value1);
}
if(whereQuery.contains('and'))
whereQuery = whereQuery.subString(0,whereQuery.lastIndexOf('and'));
system.debug('################################################'+Query);
val4 = Database.query(whereQuery);
value=new list<wrapperclass>();
// wrap = new list<Wrapper>();
for(Sobject s:val4)
{
wrapperclass wr = new wrapperclass('s.Email','s.Name',false,s.id,sno);
wr.email=string.valueof(s.get('Email'));
wr.name= string.valueof(s.get('Name'));
value.add(wr);
system.debug('^^^^^^^^^^^^^'+value);
}
system.debug('$$$$$$$$$$$$$'+value);
}
public class wrapperclass
{
public string id{get;set;}
public string name{get;set;}
public string email{get;set;}
public Boolean checked{get;set;}
public string snumber{get;set;}
public wrapperclass(string email,string name,Boolean checked,string id,Integer sno)
{
this.id=id;
this.Name=name;
this.Email=email;
this.checked=checked;
snumber=String.valueOf(sno);
}
}
/* public class wrapper
{
public Integer sno{get;set;}
public wrapper(Integer sno)
{
this.sno=sno;
}
} */
public AllUserList()
{
value = new List<wrapperclass>();
// addrow();
// wrap = new List<Wrapper>();
templates = new list<selectoption>();
templates.add(new selectoption('','--None--'));
val4 = new List<sobject> ();
rowlist = new List<Sobject>();
totalRecords=0;
String folderId = [Select Id,Name From Folder where Name = 'Email'].Id;
system.debug('????????????'+folderId );
alltemplate = new map<string,EmailTemplate>();
for(EmailTemplate fd: [Select Body, HtmlValue, Id, Name, Subject from EmailTemplate where FolderId=:folderId])
{
templates.add(new selectoption(fd.Name,fd.Name));
alltemplate.put(fd.Name,fd);
}
system.debug('++++++++++++'+alltemplate);
}
public list<selectoption> getobject()
{
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','--None--'));
for(Schema.SObjectType f : gd)
{
if(!f.getDescribe().isCustomSetting() && f.getDescribe().isAccessible() && f.getDescribe().isCreateable() && f.getDescribe().isSearchable() && f.getDescribe().isQueryable())
{
if(string.valueof(f.getDescribe().getName()) == 'Lead' || string.valueof(f.getDescribe().getName()) == 'Contact' || string.valueof(f.getDescribe().getName()) == 'User')
options.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getLabel()));
}
options.sort();
}
return options;
}
public List<SelectOption> getfd()
{
List<SelectOption> fieldsName =new List<SelectOption>();
if(objectName != null)
{
system.debug('!!!!!!!'+objectName );
Map <String, Schema.SObjectField> fieldMap= Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
for(Schema.SObjectField sfield : fieldMap.values())
{
schema.describefieldresult dfield = sfield.getDescribe();
fieldTypes.put(string.valueof(dfield.getName()),string.valueof(dfield.getType()));
fieldsName.add(new SelectOption(dfield.getName(),dfield.getLabel()));
}
}
return fieldsName;
}
public List<SelectOption> getSelect()
{
List<SelectOption> option = new List<SelectOption>();
option=getSearchOperator(Fname1);
return option;
return open;
}
public pagereference sendmail()
{
Map<id,User> allusers = new map<id,User>();
Map<id,Lead> allleads = new map<id,Lead>();
Map<id,Contact> allcontacts = new map<id,Contact>();
EmailTemplate et = alltemplate.get(templatename);
string id=et.id;
for(wrapperclass wr:value)
{
if(wr.checked==true && wr.email!=null)
{
string id1=wr.email;
String[] toAddresses = new String[] {'wr.email'};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(wr.id);
mail.setSenderDisplayName(wr.name);
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
EmailTemplate et1=[Select id from EmailTemplate where id=:et.id];
mail.setTemplateId(et1.id);
system.debug('^^^^^^^^^^^^^^^^^^^'+mail);
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
system.debug('------------------'+r);
}
}return null;
}
/*public List<SelectOption> getemailtemplate()
{
List<EmailTemplate> emailtemp = new List<EmailTemplate>();
EmailTemplate ets=[select Name from EmailTemplate];
emailtemp.add(ets);
return emailtemp;
}*/
/* public void add()
{
sno=sno+1;
addrow();
} */
public void addrow()
{
rowlist = new List<Sobject>();
totalRecords=0;
sno = value.size();
system.debug('@@@@@@@@@@@@@'+sno);
for(Sobject s:val4)
{
wrapperclass wr = new wrapperclass('s.Email','s.Name',false,s.id,sno);
value.add(wr);
}
system.debug('$$$$$$$$$$$$$$$'+value);
}
public void removerow()
{
if(value.size() > 1)
{
value.remove(value.size()-1);
}
}
}
Thanks.