You need to sign in to do that
Don't have an account?
raysfdc1988
Trigger-
trigger Attachmentant on Student_Profile__c (before insert, after insert,after update) {
if(trigger.isupdate)
{
list<Referral_Points__c> referral=new list<Referral_Points__c>();
for(Student_Profile__c s: trigger.new){
if(stoprecurssion.runonce()){
// when courcse_program name is updated, Create a new record of Referral Points///////
if(s.Course_Program__c !=null)
{
Referral_Points__c rp=new Referral_Points__c();
//////// Get the id and emailid of Referral from student_Profile //////////
Student_Profile__c referedpersonid=[select id ,Student_Profile__c.email__c from Student_Profile__c where UserName__c=:s.Referred_By_email__c limit 1];
rp.Member__c=referedpersonid.id;
rp.Refered_Person__c =s.id;
rp.Referred_by_Email__c=s.UserName__c;
referral.add(rp);
}
}
if ( !referral.isEmpty())
insert referral;
}
}
Hi,
Here I need to create a child record when only s.Course_Program__c is changed but now its creating a child record every time when other fields are updated.
I need to creat a new child record only when s.Course_Program__c is updated... Pl help me to sortout this..
Thanks
if(trigger.isupdate)
{
list<Referral_Points__c> referral=new list<Referral_Points__c>();
for(Student_Profile__c s: trigger.new){
if(stoprecurssion.runonce()){
// when courcse_program name is updated, Create a new record of Referral Points///////
if(s.Course_Program__c !=null)
{
Referral_Points__c rp=new Referral_Points__c();
//////// Get the id and emailid of Referral from student_Profile //////////
Student_Profile__c referedpersonid=[select id ,Student_Profile__c.email__c from Student_Profile__c where UserName__c=:s.Referred_By_email__c limit 1];
rp.Member__c=referedpersonid.id;
rp.Refered_Person__c =s.id;
rp.Referred_by_Email__c=s.UserName__c;
referral.add(rp);
}
}
if ( !referral.isEmpty())
insert referral;
}
}
Hi,
Here I need to create a child record when only s.Course_Program__c is changed but now its creating a child record every time when other fields are updated.
I need to creat a new child record only when s.Course_Program__c is updated... Pl help me to sortout this..
Thanks
thanks,
http://www.forcexplore.com/2014/01/salesforce-interview-questions-2.html
replace this line
if(s.Course_Program__c !=null) to
if(s.Course_Program__c !=System.trigger.oldMap.get(s.Id).Course_Program__c)
sushant sus,
sfdc_wave..........
Its working now ,...thanks a lot