• Onpursuit
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 26
    Replies
here, my requirments whenever i am creating new records on case object, insert or update to custom object cases__C, suppose i want to delete records in case objects
that corresponding records delete in custom object cases__C.how to do ?

trigger CreateCases on Case (after insert,after update)
{

  Case cs=Trigger.new[0];
   Case csold=Trigger.old[0];
  if (Trigger.isInsert)
  {
     List<cases__C> caslist=new list<cases__C>();
     Cases__c ci=new Cases__c();
     ci.Case_Number1__c=cs.CaseNumber;
     ci.Origin__c=cs.Origin;
     ci.Priority__c=cs.Priority;
     ci.Status__c=cs.Status;
     ci.Type__c=cs.Type;
     ci.Description__c=cs.Description;
     ci.Subject__c=cs.Subject;
     ci.Reason__c=cs.Reason;
     insert ci;
     //calist.add(ci);
  }
  if(Trigger.isUpdate)
  {
  
    list <Cases__c> caupdate=new list<Cases__c>();  
    caupdate=[select id,Case_Number1__c,Origin__c,Priority__c,Status__c,Type__c,Description__c,Subject__c,Reason__c from Cases__c where Case_Number1__c =: cs.CaseNumber];
     integer si=caupdate.size();
     system.debug('-------------------'+si);
    
     for(Cases__c cx: caupdate)
     {
         cx.Case_Number1__c=cs.CaseNumber;
         cx.Origin__c=cs.Origin;
         cx.Priority__c=cs.Priority;
         cx.Status__c=cs.Status;
         cx.Type__c=cs.Type;
         cx.Description__c=cs.Description;
         cx.Subject__c=cs.Subject;
         cx.Reason__c=cs.Reason;
         update cx;
     }
   }
    Case csold=Trigger.old[0];
   if(Trigger.isDelete )
   {
  
    Cases__c casdel =new Cases__c();
     casdel =[select id,Case_Number1__c from Cases__c  where  Case_Number1__c =: csold.CaseNumber ];--------> delete records coding.
     if(casdel != NULL )
     {
      delete casdel;
      }
   }
  
}
Hi,

I have 3.5 Years experience and have worked on apex,Visualforce and Integrations. I work during IST hours. Let me know if anyone have remote work.

Thanks

Hi ,

 


There is a Java app for creating contacts and show list of contact. Email field is editable and update the same in Salesforce.

 

I am using below code to update email:

 

public void updatePerson(String idx,Person perso) {
        perso.email = "test@Rah";
        getForceApi().updateSObject("Contact",idx,perso);
    }

 

But not able to make it dynamic so that it accept the edited email in the Java app field. Can anyone let me know how should i pass the edited email from JSP to controller?

I am calling a external web service using http callouts but getting a error Callout Exception: Unrecognized SSL message. 

Hi Everyone,
I have Custom object DSR is a detail object of Opportunity
-On the DSR object, when the Status = Cancelled transfer ownership or DSR record to related Opportunity Owner
thanks&regards
hari
Hey there,

I have ended up with two email triggers and I thought I would post on the forums to get help in deciding which one i should use.

Should it perhaps be one or the other or maybe even both?

I was also hoping I could get some advice on anyway that I may better the triggers. Thank you for your time:

trigger SendNewSerEmail on Service__c (after update) {
    
   
   
 //Get the correct email template here

    
List<EmailTemplate > EmailTemplate = [SELECT Id, Name FROM EmailTemplate WHERE Name = 'Destiny Survey_6Months' or Name = 'Destiny Survey_3Months' or Name = 'Destiny Survey_9Months']; 
Map<String,EmailTemplate > EmailMap = new Map<String,EmailTemplate >();
for(EmailTemplate email: EmailTemplate ){
  EmailMap.put(email.name, email);
}



    
    Set<Id> accountIds = new Set<Id>();
    for (Service__c Ser : trigger.new) {
        accountIds.add(Ser.Account__c);
    
}

    List<Account> accounts = [SELECT Id, (SELECT Id, Email FROM Contacts) FROM Account WHERE Id IN :accountIds];
    Map<Id, List<Contact>> accountMap = new Map<Id, List<Contact>>();
    for (Account acct : accounts) {
        List<Contact> contacts = new List<Contact>();
        for (Contact c : acct.Contacts) {
            contacts.add(c);
        }
        accountMap.put(acct.Id, contacts);
    }

    //It's best to make a list of emails to send, so that you can send them all at once at the end, in order to avoid hitting governor limits
    List<Messaging.SingleEmailMessage> messages = new List<Messaging.SingleEmailMessage>();
    
   for (Service__c Ser : trigger.new) {
If(Ser.Last_Email_Sent__c != 'No Emails Sent'){
         for (Contact c : accountMap.get(Ser.Account__c)) {
         if (c.Email != null) {
         
            Messaging.SingleEmailMessage m = new Messaging.SingleEmailMessage();
          If(Ser.Last_Email_Sent__c == '3 Month Support Survey (Adv)'||Ser.Last_Email_Sent__c == '3 Month Support Survey (IPC)'||Ser.Last_Email_Sent__c == '3 Month Support Survey (MOM)'){  
            EmailTemplate email = EmailMap.get('Destiny Survey_3Months');
            m.setTemplateId(email.Id);
            }
          else if(Ser.Last_Email_Sent__c == '6 Month Support Survey (Adv)'||Ser.Last_Email_Sent__c == '6 Month Support Survey (IPC)'||Ser.Last_Email_Sent__c == '6 Month Support Survey (MOM)')
           {  
            EmailTemplate email = EmailMap.get('Destiny Survey_6Months');
            m.setTemplateId(email.Id);
            }
            else if(Ser.Last_Email_Sent__c == '9 Month Support Survey (Adv)'||Ser.Last_Email_Sent__c == '9 Month Support Survey (IPC)'||Ser.Last_Email_Sent__c == '9 Month Support Survey (MOM)')
           {  
            EmailTemplate email = EmailMap.get('Destiny Survey_9Months');
            m.setTemplateId(email.Id);
            }
            m.setTargetObjectId(c.Id);
            m.setWhatId(Ser.Id);
            messages.add(m);   
        }
    }
    }
   }
    Messaging.sendEmail(messages);
    
}

trigger SendEmailtocontact on Service__c (after Update)
{
    List<String> lcontactEmails = new List<String>();
    Set<Id> sIds = new Set<Id>();
//Added
    Set<ID> accIds = new Set<ID>();
    for(Service__c qItr : Trigger.new)
{
        if(Trigger.isUpdate)
  {
            if(Trigger.oldmap.get(qItr.id).Service_Stage__c != qItr.Service_Stage__c && qItr.Service_Stage__c.containsIgnoreCase('Stage 4'))
   {
                sIds.add(qItr.id);
    //Added
    accIds.add(qItr.Account__c);
            }
        }
  //Will Never Execute as trigger will fire only if a record is updated
        else if(Trigger.isInsert)
  {
            if(Trigger.newMap.get(qItr.id).Service_Stage__c.containsIgnoreCase('Stage 4'))
   {
                sIds.add(qItr.id);
            }
        }
    }
// Modified
    //for(Account accItr : [SELECT id,(SELECT id FROM Contacts) FROM Account WHERE id IN (SELECT Account__c FROM Service__c WHERE Id IN: sIds)])
for(Account accItr : [SELECT id,(SELECT id FROM Contacts) FROM Account WHERE id IN : accIds])
{
        for(Contact con : accItr.contacts)
  {
            if(!String.isBlank(con.id))
   {
                lcontactEmails.add(con.id);
            }
        }
       // No need to put this condition here.
  /*if(!lcontactEmails.isEmpty())
  {
   EmailHandler.sendEmail(lcontactEmails);
  }*/   
    }
//Put this here
if(!lcontactEmails.isEmpty())
{
for(Service__c serv : Trigger.new)
{
if(Serv.Service_Name__c == 'Advantage Program')
{
        EmailHandler.sendADVEmail(lcontactEmails);
    }
    
if(Serv.Service_Name__c == 'Essential Property Education')
{
        EmailHandler.sendEPEEmail(lcontactEmails);
    } 
    }   
}
}


I'm getting the "Too many SOQL queries" error on Line 17. Help me troubleshoot?

trigger InsideSalesAppointment on Task (after insert, after update) {

Map<Id,Date> LeadsToUpdate = new Map<Id,Date>();
List<User> InsideSalesUser = [SELECT Id FROM User where UserRoleId='00E30000001rctV'];
Set<Id> InsideSalesUserId = new set<Id>();
for (User u :InsideSalesUser) {
    InsideSalesUserId.add(u.Id);
    }


for (Task t: Trigger.new) {
    if(InsideSalesUserId.contains(t.OwnerID) && t.IsClosed == false && String.valueOf(t.WhoId).startsWith('00Q') && t.WhoId != NULL)
    
    LeadsToUpdate.put(t.WhoId, t.ActivityDate);
    }

List<Lead> LeadsAppointment = [SELECT Id FROM Lead where Id IN:LeadsToUpdate.keyset()];

if (LeadsToUpdate.keyset().size()>0){

for (Lead l: LeadsAppointment) {

    l.Next_Appointment_Date__c = LeadsToUpdate.get(l.id);
    }
    update LeadsAppointment;
}
}


Hi,
Can some one help me how to use Schema spy for extracting ERD from Salesforce Org?

Many Thanks in advance:)



Hi,

I have 3.5 Years experience and have worked on apex,Visualforce and Integrations. I work during IST hours. Let me know if anyone have remote work.

Thanks
here, my requirments whenever i am creating new records on case object, insert or update to custom object cases__C, suppose i want to delete records in case objects
that corresponding records delete in custom object cases__C.how to do ?

trigger CreateCases on Case (after insert,after update)
{

  Case cs=Trigger.new[0];
   Case csold=Trigger.old[0];
  if (Trigger.isInsert)
  {
     List<cases__C> caslist=new list<cases__C>();
     Cases__c ci=new Cases__c();
     ci.Case_Number1__c=cs.CaseNumber;
     ci.Origin__c=cs.Origin;
     ci.Priority__c=cs.Priority;
     ci.Status__c=cs.Status;
     ci.Type__c=cs.Type;
     ci.Description__c=cs.Description;
     ci.Subject__c=cs.Subject;
     ci.Reason__c=cs.Reason;
     insert ci;
     //calist.add(ci);
  }
  if(Trigger.isUpdate)
  {
  
    list <Cases__c> caupdate=new list<Cases__c>();  
    caupdate=[select id,Case_Number1__c,Origin__c,Priority__c,Status__c,Type__c,Description__c,Subject__c,Reason__c from Cases__c where Case_Number1__c =: cs.CaseNumber];
     integer si=caupdate.size();
     system.debug('-------------------'+si);
    
     for(Cases__c cx: caupdate)
     {
         cx.Case_Number1__c=cs.CaseNumber;
         cx.Origin__c=cs.Origin;
         cx.Priority__c=cs.Priority;
         cx.Status__c=cs.Status;
         cx.Type__c=cs.Type;
         cx.Description__c=cs.Description;
         cx.Subject__c=cs.Subject;
         cx.Reason__c=cs.Reason;
         update cx;
     }
   }
    Case csold=Trigger.old[0];
   if(Trigger.isDelete )
   {
  
    Cases__c casdel =new Cases__c();
     casdel =[select id,Case_Number1__c from Cases__c  where  Case_Number1__c =: csold.CaseNumber ];--------> delete records coding.
     if(casdel != NULL )
     {
      delete casdel;
      }
   }
  
}
Hi,

I want to change a case status, but every time I change it, the Owner field changes as well. Even trying to change Owner back to its previous value won't work.

I suspect this is done by a trigger in the backend side, but I can change the Status through the web interface and I don't see this behaviour.

Thanks in advance.
Is it possible to pick values ​​between SELECT and FROM (String) and use the code in Apex?

Example: the user informe = SELECT casenumber,subject,Contact.Name,status FROM Case WHERE ClosedDate=TODAY
The Apex code uses only: casenumber, subject, Contact.Name, status to build a CSV::::

...
string titre= 'casenumber,subject,Contact.Name,status'+'\n';

...

for(Case a: (List<case>)database.query(caseTT) )
{
   string contenu = a.casenumber + ',' + a.subject+ ',' +a.Contact.Name+ ',' + a.status +'\n';
   contenuCSV = contenuCSV + contenu ;
}

....

Thank you!!!
hai friends
 i want to query the related opportunity of account into trigger(after insert).i wrote a query by using trigger.new here i am getting newly inserted record also why because it is executing after insert.i want previous opportunity only into trigger.isafter.


i will explain with example
for account three opportunities are there.now i am adding fourth one (i want previous three opportunity records into trigger.isafter of trigger on opportunity not fourth one) can any one please help me (i come to know this is achieved by trigger.oldMap in trigger.isafter)
I am trying to update a few records with email id whenever a user updates his email in the user record. I wrote the trigger on User object however the trigger is not firing since an email is first sent over on email update which then requires confirmation from user. 

Any ideas on what can be done?
I am getting this error when i was updating custom object,i used @future also