• mohi
  • NEWBIE
  • 110 Points
  • Member since 2010

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 57
    Replies

 

I want to do similar thing below , but using a Map, is there any similar funcationality available?

 

The list or set iteration for loop iterates over all the elements in a list or set. Its syntax is:


for (variable : list_or_set) {
code_block
}

 

where variable must be of the same primitive or sObject type as list_or_set. When executing this type of for loop, the Apex runtime engine assigns variable to each element in list_or_set, and runs the code_block for each value. For example, the following code outputs the numbers 1 - 10 to the debug log:

 

Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (Integer i : myInts) {
System.debug('test test');

}

 

 

I tried this but got error, 

 

public Map<Integer, myClass>  myItems;

 

for (myClass item : this.myItems){}

 

Save error: Loop must iterate over a collection type: MAP<Integer,myClass> :( 

 

Can anyone help on this?

 

Thanks 

 

Need some assistance on apex sharing trigger for after update and after insert. Need to provide the edit access to the respective backup user (Backup_person__c field). It is on the custom object.

 

appreciate your help.

Hi All,

 

I'm relatively new to writing in Apex, so forgive me if it looks like I'm making rookie mistakes - I probably am making rookie mistakes :)

 

Myself and a colleague are trying to perform a cleanup of some old data.  We have a field called "Lead Source," which is a picklist with around 8 or so values.  The powers that be have come up with 7 or so different values that make more sense than the initial 8, so our task is to map the old values to their respective new ones.  Altogether, there are around 40,000 records that need to be adjusted.  

 

We've decided to approach this by writing a simple apex class in our sandbox:

 

 

public class leadSourceMap {
    public VFConnect(ApexPages.StandardController controller) { }
        public static void changeSource(){
        Account[] acclist = [SELECT Id,Lead_Source__c FROM account WHERE account.Lead_Source__c =  'Direct'];
        for(account a:acclist){
        if (a.Lead_Source__c == 'Direct') {
         a.Lead_Source__c = 'Rep Needs To Ask';
         }
         try { update a; } catch ( System.DmlException e) {
 
            system.assert(e.getMessage().contains('irst error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A lead with this email address already exists'),
                e.getMessage());   
                
        }
    }

}
}

 

We couldn't figure out how to make this run, so we decided to build a simple visualforce page that just called the changesource method when any account was accessed:

 

 

 

<apex:page standardController="Account"
 extensions="VFConnect"
 action="{!changeSource}"
>
  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>

 To our great joy, this script worked when we tested it on a batch of 25 accounts that we had loaded into my sandbox.  Unfortunately, when I tried it on about 500 accounts, it returned this error:

 

Content cannot be displayed: Assertion Failed: Update failed. First exception on row 0 with id 001P000000HMwuFIAT; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EDP1.ActivityReset: execution of AfterUpdatecaused by: System.LimitException: EDP1:Too many SOQL queries: 101(EDP1): []

 

It looks like we're querying the database for each action, but I meant to write our apex such that it queried once and then pulled from that array to go through and make the appropriate changes.  Any help on both the SOQL question and on how we might be able to architect this better would be greatly appreciated!

 

Thank you all!

 

 

 

 

Hi,

 I associated two permission set to user,but when i  query on permissionsetAssignment Object,and tried to get permissionset associated with that user it gives me three records ,while it should show only two.

 

any help appreciated. 

  • August 09, 2012
  • Like
  • 0

Hi,

 

I am facing problem using describe call ,i am reteriving sobject and fields,but i am hitting limit of describe calls.

Can any body have some insight ..please tell 

  • May 15, 2012
  • Like
  • 0

Hi , I am creating flow , Can any one tell me how to validate my data.lik duplicate .

 

Please Provide Its urgent.

  • May 05, 2012
  • Like
  • 0

Hi,

 

i am facing issue lik i have 3 object OBj1,Obj2,Obj3, and show data as per role hierarchy, if i am top hierarchy level that is pulling data for all user in the org bt ,

My data is more than 4 lack for a object and for a single user more than 50 thosands, i am makig aggregate results.

 

Facing error :too many query row reterived.. cany any one tell me how to handle this situation.with best approach ,standard reprt not required..

  • May 03, 2012
  • Like
  • 0


 

 when i am making a group by Formula field in soql i am hitting this error can any one help to to resolve out.

 

Illustration:

Query =[select id,sum(a__c) from account group by OwnerId,Formulafield__c];

 

System.UnexpectedException: field 'Product_Family__c' can not be grouped in a query call

  • April 16, 2012
  • Like
  • 0

Hi, i m facing problem to send mass email to contacts in Dev Org but error is thrown

"NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature"

  • September 13, 2010
  • Like
  • 0

hi , pls help me out  for open visualforce page as lightbox on clicking detail page link button

thanks

  • July 14, 2010
  • Like
  • 0

Hi

list<navpa__Fundraising__c> firstclosing=[select navpa__Fund_Manager__c,navpa__Investment_Likely_Amount_USD_mn__c ,Probability__c,sum(navpa__Investment_Likely_Amount_USD_mn__c) total,Probability_Weighted__c,navpa__Closing__c from navpa__Fundraising__c where (navpa__Institution_Name__c=:uidd and navpa__Closing__c='1st Closing') Group By  navpa__Closing__c];

 

Error message:Field must be grouped or aggregated: navpa__Fund_Manager__c at line,if i remove the sum function& group by clause it brinhgs record, as i use aggregate function it shows error plz specify.

  • July 02, 2010
  • Like
  • 0

Hi i using this code

<script type="text/javascript">

var  wn=window.open('+"{!URLFOR($Page.caserelscheme)}"+');

</script>

Error: page does not exist check spelling.

pls help

  • June 25, 2010
  • Like
  • 0

private String lastName {get; set;}
public geparameter()
{
String uidd=ApexPages.currentPage().getParameters().get('useridd');
System.debug('@@@'+uidd);
List<CandidateInfo__c>  myCandidate=[select id,LastName__c,FirstName__c from CandidateInfo__c where id=:uidd ] ;
for(CandidateInfo__c t: myCandidate)
{
this.lastName=t.lastname__c;
this.firstName=t.firstname__c;
}
}
}

  • June 22, 2010
  • Like
  • 0

i hve two custom object

with lookup relationship obj2 has three record type,

when i m creating obj1 it should create three field according to recoed type.

trigger LicenceInsert on Licence__c (after insert) 
{
Licence__c c=new Licence__c ();
System.debug(trigger.new[0].id);
if(c.id !=null)
{
List<OtherActivity__c> OtherActivity= new List<OtherActivity__c>();
OtherActivity__c a=new OtherActivity__c();
a.RecordTypeId='01290000000TdtQAAS';
a.DatamigrationApplicable__c='Yes';
a.DMTypeOnboarding__c='Yes';
a.LicenceID__c='trigger.new[0].id';
a.MigrationType__c='free';
OtherActivity.add(a);
OtherActivity__c b=new OtherActivity__c();
b.RecordTypeId='01290000000TdtLAAS';
b.LicenceID__c='trigger.new[0].id';
b.PaidTraining__c='no';
b.TrainingType__c='onboarding';
OtherActivity.add(b);
OtherActivity__c t=new OtherActivity__c();
t.RecordTypeId='01290000000TdtGAAS';
t.LicenceID__c='trigger.new[0].id';
t.UserSetUPStatus__c='Create';
OtherActivity.add(t);
insert OtherActivity;
}
}
no error but it is not creating data according to record type
  • June 17, 2010
  • Like
  • 0

hi i hve custom obj candidateinfo__c:

DemoCountri picklist

trigger testchkboxtrigger on CandidateInfo__c (after update)
{
for(CandidateInfo__c c:trigger.new)
    {
    if(c.DEmoCountry__c =='us')
    {
       c.Home__c = true;
    }
    }
update  trigger.new;
}

plshelp trigger if fire exception

  • June 11, 2010
  • Like
  • 0

whn i m using <apex : inputfile required="true">

on saving file i get error  j_id0:j_id2:j_id30:block1:j_id35:file: Validation Error: Value is required

do i can customize that error. "j_id0:j_id2:j_id30:block1:j_id" without javascript

  • June 10, 2010
  • Like
  • 0

hi

i have develop an app, but for certain user which is a basic user it is not showing the all the application tab,

it is just showing the  home tab plz help

Thanks

  • May 04, 2010
  • Like
  • 0

Dear sir/mam

pls specify how to achieve  the functionality

thanks

  • April 29, 2010
  • Like
  • 0

plz provide some illustration on the Record Type New to salesforce.

Thanks

 

  • April 28, 2010
  • Like
  • 0

As I m new to the sf

i know how to use controler extension but don't know whyyyyyyyy

plz help

Thanks

  • April 22, 2010
  • Like
  • 0
  • April 16, 2010
  • Like
  • 0
dear i made a custom object candidaeinformation with feild; firstname , last name ,password ,phone ,email Error: token error this is for login:controller public class Registration { private string FirstName{get;set}; private string password{get;set}; public String getFirstName() { return this.firstName; } public String getpassword() { return this.password; } public void setFirstName(String FirstName) { this.FirstName = FirstName; } public void setpassword(String FirstName) { this.Password = Password; } list mylogin=[select firstname, password from candidateinformation]; public PageReference save () { for(candidateinformation c: mylogin) { if(c.firstname==firstname && c.password==password) { page.success; } } return null; } } visualforcepage:unknown property firstname >
  • April 15, 2010
  • Like
  • 0
  • April 13, 2010
  • Like
  • 0

HI have one trigger  sending mail , i need to test coverqage for that tigger , My trigger

 

is

trigger sendemail on Anxiety_Survey_del__c (before insert,before update) {
for(Anxiety_Survey_del__c ase:trigger.new){
if(trigger.isinsert){
Integer cou=0;
cou=[select count() from Anxiety_Survey_del__c where Patient__c=:ase.Patient__c and Surevey_Number__c>:0 limit 4];
If(ase.Anxiety_Date_and_Time__c!=null)
ase.X30_days_mail__c=date.NewInstance(ase.Anxiety_Date_and_Time__c.year(),ase.Anxiety_Date_and_Time__c.month(),ase.Anxiety_Date_and_Time__c.day()).adddays(30);
If(cou<4)
ase.Surevey_Number__c=cou+1;
}
if(trigger.isupdate){
If(ase.Survey_Created__c==false){
Integer cou=[select count()from Anxiety_Survey_del__c where Patient__c=:ase.Patient__c and Surevey_Number__c>:ase.Surevey_Number__c limit 1];
If(cou==0)
{
list<feeditem> posts=new list<feeditem>();
list<Send_Email__c> emails=new list<Send_Email__c>();

if((ase.Temp__c=='Temp172'&&Trigger.oldmap.get(ase.id).Temp__c!='Temp172')||(ase.Send_Daily_email__c!=null)){
string days;
 If(ase.Surevey_Number__c>0&&ase.Surevey_Number__c<4)   
                    days=ase.Surevey_Number__c*30 +' days';
                    patient__c p1=[select id,Name,ownerid,Last_name__c from patient__c where id=:ase.patient__c limit 1];
                   User p=[select id,email from user where id=:p1.ownerId limit 1];
                   If(p!=null){
                    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                    String[] toAddresses =new string[]{p.email};
                    mail.setToAddresses(toAddresses);
                    string sub='This is time for Another Survey for Patient '+p1.Name+' '+p1.Last_name__c ;
                    mail.setSubject(sub);
                    mail.setBccSender(false);
                    mail.setUseSignature(false);                     
                   
                    mail.plaintextbody='This is time for '+days +' Survey for Patient '+p1.Name+' '+p1.Last_name__c ;              
                    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                    }
                    //System.debug('$$$$$'+p1.ownerId);
                    FeedItem post = new FeedItem();
                    post.ParentId = p.Id;
                    post.Body = 'This is time for '+days +' Survey for Patient '+p1.Name+' '+p1.Last_name__c ; // And i was... super simple :D
                    posts.add(post);
                    If(ase.Temp__c=='Temp172'&&Trigger.oldmap.get(ase.id).Temp__c!='Temp172'){
                    Send_Email__c email1=new Send_Email__c();
                    email1.Date_to_send__c=ase.X30_days_mail__c.adddays(1);
                    email1.Anxiety_Survey__c=ase.id;
                    emails.add(email1);
                    }
                    
                    
}
if(posts.size()>0)
insert posts;
If(emails.size()>0)
insert emails;
}
else
ase.Survey_Created__c=true;
}
}
}
}

 

 

I wrote test test class for the trigger bu t i don;t know how to  write text  fo r senfin mails plz help me

 

 

 

@isTest
Private class Testsendemail
{
private static TestMethod void Testsend1()
{
  Patient__c  p =new Patient__c(E_LastName__c='xxxx',E_Electronic_Chart_ID__c='aaaaaa');
 insert p;
 Patient__c  p1 =new Patient__c(E_LastName__c='yyyyy',E_Electronic_Chart_ID__c='zzzzz');
 insert p1;
 Anxiety_Survey_del__c  a=new Anxiety_Survey_del__c(Name='aaaaa',Patient__c =p.id,Survey_Created__c=false,Surevey_Number__c=3,Anxiety_Date_and_Time__c=system.today(),Temp__c='aaaa');
 insert a;
 Anxiety_Survey_del__c  a1=new Anxiety_Survey_del__c(Name='bbbb',Patient__c = p.id,Survey_Created__c=false,Surevey_Number__c=3, Anxiety_Date_and_Time__c=system.today(),Temp__c='bbbbb');
 //insert a1;
  }
  }

 

HI 

 

we have some common functionlity in triggers on different objects.like:

 

trigger 1

{

 

      if(aa="qwe")

       {

              xyz ="sss";

 

        }

}

trigger 2

{

 

      if(aa="qwe")

       {

              xyz ="sss";

 

        }

}

trigger 3

{

 

      if(aa="qwe")

       {

              xyz ="sss";

 

        }

}

 

 

but operate on different objects.

 

so is thr any way that block of code start from if will place somewhere else and we just refere that  in triggers..so in case any change ,will be done on that and reflect in all the triggers

 

thanks 

 

 

I am trying to create a user using Apex class for which I have written the following code.

<Previous Code>
User user = new User();

user.FirstName = String.valueOf(usr.FirstName);
user.LastName = String.valueOf(usr.LastName);
user.Username = String.valueOf(usr.UserName);
.
.
.
<set the values for all the required field>
Upsert user;
<Following Code>

When i am trying to save the class, I am facing the following error.

"DML not allowed on User".

Please suggest.

Hi ..

 

try{
 opportunity o=[select id from opportunity where name='xxx'];
}
catch(exception e)
{}
now i need to caught the exception
when trigger fails
how to catch and display when records are not getting
while executing the trigger
 
thanks in advance
  • May 30, 2012
  • Like
  • 0

Hi , I am using a single controller for 2 vf pages .What i am doing is the user will enter values in first page and once they click search , only the matching trains will be available in the data table with check box in another page.

The problem is the values aren't getting set in the instance pass. **  getting null values in pass.from__c , pass.to__c and pass.Journey_Date__c in the if loop of controller. Please help !

 

1st page :

<apex:page standardController="Train_Details__c" extensions="RailwayReserveNew">
 <apex:sectionHeader title="Passenger Details Edit" subtitle="New Passenger Details"/>
 <apex:form >
 <apex:pageBlock title="Passenger Details Edit">
 <apex:pageBlockSection columns="1" >   
 <apex:inputField value="{!pass.Booker_Name__c}"  />
 <apex:inputField value="{!pass.Total_Senior_Citizens__c}"  />
<apex:inputField value="{!pass.Total_Children_Age_below_6__c}"  />
<apex:inputField value="{!pass.Total_Passengers__c}"  />
<apex:inputField value="{!pass.From__c}"  />
<apex:inputField value="{!pass.To__c}"  />
<apex:inputField value="{!pass.Journey_Date__c}"  />
<apex:inputField value="{!pass.Fare__c}"  />

</apex:pageBlockSection>
<apex:pageBlockButtons >
 <apex:commandButton value="search" action="{!dosearch}"/>
 <apex:commandButton value="save" action="{!save}"/>
 </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Controller :

 

public  class RailwayReserveNew {

List<trainwrapper> wrapperList=new List<trainwrapper>();
List<Passenger_Details__c> passList=new List<Passenger_Details__c>([SELECT From__c,To__c,Journey_Date__c FROM Passenger_Details__c]);
List<Train_Details__c> selectedTrains=new List<Train_Details__c>();
List<Train_Details__c> trainDetails=new List<Train_Details__c>([select Name,Starting_Point__c,Destination__c,EveryDay__c,Monday__c,Tuesday__c,Wednesday__c,Thursday__c,Friday__c,Saturday__c,Sunday__c FROM Train_Details__c]);
private final Train_Details__c acct;


public Passenger_Details__c pass{
get;
private set;}


public RailwayReserveNew(ApexPages.StandardController stdController) {
        this.acct = (Train_Details__c)stdController.getRecord();
            Passenger_Details__c pass=new Passenger_Details__c();

            }

 public  List<trainwrapper> getavailabletrains() {


for(Train_Details__c t: trainDetails) {

if(t.Starting_Point__c==pass.from__c && t.Destination__c==pass.to__c) {

if(t.EveryDay__c==true) {

 

wrapperList.add(new trainwrapper(t));
}

 

else if(t.EveryDay__c==false) {

String journeyDay = Datetime.newInstance(pass.Journey_Date__c, Time.newInstance(0, 0, 0, 0)).format('E').substring(0, 2);
system.debug('**************************' + journeyDay);

if(journeyDay=='Mo' && t.Monday__c==true) {
system.debug('**************************' + journeyDay);
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='Tu' && t.Tuesday__c==true) {
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='We' && t.Wednesday__c==true) {
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='Th' && t.Thursday__c==true) {
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='Fr' && t.Friday__c==true) {
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='Sa' && t.Saturday__c==true) {
wrapperList.add(new trainwrapper(t));
}
if(journeyDay=='Su' && t.Sunday__c==true) {
wrapperList.add(new trainwrapper(t));
}

}
}

}
return wrapperList;

}

public pagereference GetSelected() {
selectedTrains.clear();
for(trainwrapper trainwrapper:wrapperList)
if(trainwrapper.selected==true) {
selectedTrains.add(trainwrapper.trainwrap);
}
return null;

}

public List<Train_Details__c> GetSelectedTrains()
    {
        if(selectedTrains.size()>0)
        return selectedTrains;
        else
        return null;
    }

 

 

public class trainwrapper  {

public Train_Details__c trainwrap{get;set;}
public boolean selected {get;set;}

public trainwrapper(Train_Details__c tr)
{

trainwrap=tr;
selected=false;
}

}

public pagereference dosearch(){
return page.railwayreserve;
}

public pagereference save() {
upsert (pass);
return null;
}

}

2nd page :

 <apex:page standardController="Train_Details__c" extensions="RailwayReserveNew">

<apex:form >
<apex:pageBlock title="Available Trains"> 
<apex:dataTable value="{!availabletrains}" var="trains" columns="3" border="2" cellpadding="2">

<apex:column >
<apex:inputCheckbox value="{!trains.selected}" id="checkedone">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_Train"/>
</apex:inputCheckbox></apex:column>

<apex:column headerValue="Name" value="{!trains.trainwrap.Name}"/>
<apex:column headerValue="From" value="{!trains.trainwrap.Starting_Point__c}"/>
<apex:column headerValue="To" value="{!trains.trainwrap.Destination__c}"/>

</apex:dataTable>


<apex:pageBlock Title="Selected Train" id="Selected_Train">
<apex:dataTable value="{!SelectedTrains}" var="s" columnswidth="50px,50px" cellpadding="4" border="1">
<apex:column headervalue="Name" value="{!s.Name}" />
<apex:column headervalue="From" value="{!s.Starting_Point__c}" />
<apex:column headervalue="To" value="{!s.Destination__c}" />
</apex:dataTable>
</apex:pageBlock>

 


</apex:pageBlock>

</apex:form>
</apex:page>

Hi 

i have two fields name :

 

Actual Program1
Actual Cost1
need to be require when we click  'convert'  button on lead page.
thanks in advance

i need to traverse through 4 levels in an XML using apex can some body suugest a method for doing that


example

<left1><left2>
<left3>
<left4>
help
</left4></left3>
</left2></left1>


i need to get the value of ""help"".Can some body suggest a way of traversing a large amount of elements in xml

Shine

When invoking Datebase.saveResult and trying to collect the errors, it only seems to get the  first error and ignores other errors.

For example suppose i have 2 fields on an object and have validation on each of them. If I try and get the errors via getErrors(), only the error on the first field is retrieved. This seems different from how the errors are show on the UI - both validation errors are show on the UI.

  • May 27, 2012
  • Like
  • 0

I'm trying to assign the date of a project parent object to the maximum date due of related child tasks.

I'm getting a "Save error: Expression cannot be assigned" error message based on the second variable setNewDueDate()

	P1Task__c maxTaskDate = [SELECT  Due__c							
						FROM Page1Task__c
						WHERE Project__c = :this.currentTask.Project__c 
						AND Status__c != '6) Completed'
					        AND Status__c != '5) Deferred'
						AND Seq__c > :this.currentTask.Seq__c
						AND Due_Date_Auto_Calc__c = 'Always'
						AND Lag_Days__c != null
						ORDER BY Seq__c DESC
						LIMIT 1];
    
	public void setNewDueDate(){
		if(P1Project__c.Due__c != maxTaskDate.Due__c){			
			P1Project__c.Due__c = maxTaskDate.Due__c;
			}
		}

 

Now, I've tried this as well and it doesn't like it either.

 

  • May 19, 2012
  • Like
  • 0

Hi

 

I Have two button in opportunity page one is "Save" which is by default and other is custom button "Send Confirmation"

When user click in the "Save" button the activity history is saved(dont how it happen)

Same functionality is needed on custom button click.

 

Any body have any idea..plz help.

 

thanks

Hi All ,

 

 I have one case field lke the format "mm/dd/yyyy  hh:mm AM/PM"  i.e(3/7/2012 5:07 AM).From this i want to get month value.i.e here 3.How can i get this.

 

 I tried this way

MONTH(DATEVALUE(c.CaseCreated__c)), but it is giving an error "Incorrect parameter for function 'DATEVALUE()'. Expected Text, received java.util.GregorianCalendar".

 

I con't get solution for this.please help.! Any help greatly appreciated:)

 

I want to do similar thing below , but using a Map, is there any similar funcationality available?

 

The list or set iteration for loop iterates over all the elements in a list or set. Its syntax is:


for (variable : list_or_set) {
code_block
}

 

where variable must be of the same primitive or sObject type as list_or_set. When executing this type of for loop, the Apex runtime engine assigns variable to each element in list_or_set, and runs the code_block for each value. For example, the following code outputs the numbers 1 - 10 to the debug log:

 

Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (Integer i : myInts) {
System.debug('test test');

}

 

 

I tried this but got error, 

 

public Map<Integer, myClass>  myItems;

 

for (myClass item : this.myItems){}

 

Save error: Loop must iterate over a collection type: MAP<Integer,myClass> :( 

 

Can anyone help on this?

 

Thanks 

 

Hi,

 

i have a situation where i need to send email to multiple users with an email template

 

please check the below link, its mentioned there, to use email template we always need to set setTargetObjectId to Contact.Id

 

http://www.forcetree.com/2009/07/sending-email-from-your-apex-class.html

 

so to send email to two users we need to create two contacts first then after use delete like this

 

            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
            Contact con =  new Contact();
            con.FirstName = 'Anil';
            con.LastName = 'Dutt';
            con.Email = 'anil@swiftsetup.com';
            insert con;
        
            mail.setTargetObjectId(con.id);
            mail.setWhatId(it.Id);
            mail.setTemplateId('00Xd0000000PIwh');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
            delete con;

 

 

            Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
            

            Contact con1 =  new Contact();
            con1.FirstName = 'Anil';
            con1.LastName = 'Dutt';
            con1.Email = 'anildbest83@gmail.com;
            insert con1;
        
            mail1.setTargetObjectId(con1.id);
            mail1.setWhatId(it.Id);
            mail1.setTemplateId('00Xd0000000PIwh');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail1 });
            delete con;

 

Now above code works fine , send email to both the users but

 

Firstly, this becomes bulky if number of users are very large

2nd, in the chatter, it shows

           Anil Dutt - anild created this contact

           Anil Dutt - anild created this contact

 

so above code create contact and then delete but it shows in chatter that a contact has been created

 

Is there any better way to accomplish above?

 

Please advise

 

Thanks

Need some assistance on apex sharing trigger for after update and after insert. Need to provide the edit access to the respective backup user (Backup_person__c field). It is on the custom object.

 

appreciate your help.

 

I have a problem validating an inbound change set from a sandbox. The change set consists of 4 custom objects and some email templates. I was getting errors originally with workflow rules, so I deleted all the workflow rules.

Now I get one "FAILED" deployment result as follows:

 

API NameTypeLineColumnProblem: deletecontroller.Testdeletedata()

Class 12

Failure Message: "System.LimitException: Too many DML rows: 10001", Failure Stack Trace: "Class.deletecontroller.deletedata: line 13, column 1 Class.deletecontroller.Testdeletedata: line 18, column 1"

 

I have tried object by object deployment to isolate the error, and I still get the same error.

Any suggestions for help on getting rid of or isolating the error?


  • April 02, 2012
  • Like
  • 0

hi i have  wrote an controller 

actuall in my controller these method is not covered

Public void deltsheet()
{
String rownumber = System.currentPagereference().getParameters().get('rownumber');
Decimal rownumb = Decimal.Valueof(rownumber);
Integer rowno = rownumb.IntValue();
String tentryid = System.currentPagereference().getParameters().get('tentryid');
if (rownumber != '')
tentries.remove(rowno);

}

 

how to declare the above method in my testcase so that my coveragemay increase actuall how to declare rownumber

tentryid

in my testcase so that my coverage may increase

 

thanks in advance

 

 

 

  • March 20, 2012
  • Like
  • 0

Hello,

 

My request is on the title. It seems to be simple, but I don't find a simple explanation to do that:

How do I pass data, from controller to javascript?

 

The situation is:

I have a controller which get some data from the database :

public with sharing class recup_donnees_test_Controller {
    
    Public LIST<Calendrier__c> GetCalendriers(){
            return Calendriers_Interne;
    }
    
    Public void SetCalendriers(LIST<Calendrier__c>Calendriers){
            Calendriers_Interne = Calendriers;
    }   

    Private LIST<Calendrier__c>Calendriers_Interne = new LIST<Calendrier__c>();

    Public recup_donnees_test_Controller (){
        
        Calendriers_Interne = [Select c.nom__c, c.id__c, c.Tache__c, c.SystemModstamp, c.Ressource__c, c.OwnerId, c.Name, c.LastModifiedDate, c.LastModifiedById, c.LastActivityDate, c.IsDeleted, c.Id, c.Heure_Fin__c, c.Heure_Debut__c, c.Date__c, c.CreatedDate, c.CreatedById, c.Categorie__c From Calendrier__c c WHERE c.Ressource__c = 'FRANCO-IDRISS Béatrice'];

    }
   

}

And then i have a Visual Force page, in which would like to get the data

 

Visual force page:

<apex:page Controller="recup_donnees_test_Controller" >

    <apex:pageBlock title="Calendrier">
    <apex:pageBlockTable value="{!Calendriers}" var="c">
        <apex:column headerValue="nom" value="{!c.nom__c}"/>
        <apex:column headerValue="Tâche" value="{!c.Tache__c}"/>
        <apex:column headerValue="Ressource" value="{!c.Ressource__c}"/>
        <apex:column headerValue="Date" value="{!c.Date__c}"/>
        <apex:column headerValue="Heure Début" value="{!c.Heure_Debut__c}"/>
        <apex:column headerValue="Heure Fin" value="{!c.Heure_Fin__c}"/>
 
    </apex:pageBlockTable>
</apex:pageBlock>



</apex:page>

 

if someone could help me?

Thank you

 

Emmanuel

  • November 10, 2011
  • Like
  • 0

Hey all,

 

I am having an issue where a SELECT statement is only returning the first 20 records, despite the fact that I have not placed any limits on it. Is there a limit of 20 for what a SELECT can return?

 

If not, I can post my code to see if anyone can help me with why my query is being limited.

 

Thanks!

-Derrek