• Sindhu Nagabhushan
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 6
    Replies
We are using Email-To-Case feature. 
I have a custom email field on case. When a new case is created, i want to send an automatic email to that email field along with the attachments in "Attachments related list".

How to do this using apex trigger?
Hi,
I have written the below trigger to update the campaign member status. But its not working and i am not able to figure out why
Thanks for help in advance.

trigger UpdateCampaignStatus on FeedBack__c (after insert,after update) {
    try{
    set<id> fid=new set<id>();
    for(feedback__c fb:trigger.new)
    {
        if(fb.recordtypeid=='01250000000UNZH')
        {
            list <CampaignMember> cm=[select id,status from CampaignMember where contactid=:fb.contact__c and campaignid=:fb.Campaign__c];
            cm[0].status='Completed';
            Update cm[0];
        }     
    }
    }catch(exception e)
    {
        system.debug(e.getmessage());
    }
        }
I have the below requirement to create VF page. I am new to this. Someone please give me an idea on how to do this.
User-added image
Would utilize Contact Role section of Account object – names of each Contact would appear in the appropriate section of the image. If the name does not exist in the contact role related list, "TBD" should be entered.
 
Hi,
 
i have the below requirement and i am new to visulaforce. Someone please provide an idea on how to create this.

I want to create a table with all the picklist values available. when i add this VF page to page layout, the corresponding picklist value for that record should be highlighted in my table, Like the image below --
User-added image
Thanks for your help in advance.
Hi,
I need help in writing before insert trigger on Email Message
My Requirement is - 
    If sender address is already present in web email of any case, the incoming email should attach to that case.
    
    Please help me how to write this trigger.
    I have created thread id formula field to update the thread id of the case.

Thanks in Advance
Hi,
 i need to write a apex trigger to achieve this - 
When a task is created related to opportunity or contact, i want to stamp the related account info in a text field. 
But i will get only related-to Id, how can i get the account information from the related-to ID

Someone please help me,

Thanks in advance
map<id,aggregateresult> accmap=new map<id,aggregateresult>([select account__r.id,avg(nps__c)np,avg(Average_Score__c)avs from feedback__c where createddate=this_quarter and account__c=:accex group by account__r.id]);

This is my query.
I want to read the value of avg(nps__c) for a particular account and store that value in a new field.
How do i refer to that field?
I tried something like ar.np  but it does not work


Thanks in advance
Hi,
Please help me with this requirement

I have 'score' field on objectA and this object has lookup relationship to account.
I want to take average of 'score' field on all objectA records created in current quarter and stamp that value on account.


Thanks in advance
I have a competitor object. It has lookup and Master-detail relationship to Account Object. When i try to mass insert records, I get the follwing error
"autoinsertforcompetitor: execution of BeforeInsert caused by: System.ListException: Before Insert or Upsert list must not have two identically equal elements Trigger.autoinsertforcompetitor: line 48, column 1"

Here's my code

trigger autoinsertforcompetitor on Competing_Customer__c (before insert,after delete)
{
         list<Competing_Customer__c> newcompetitor=new list<Competing_Customer__c>();
     list<Competing_Customer__c> competitorlist=new list<Competing_Customer__c>();
     Competing_Customer__c competitor = new Competing_Customer__c();
   
    if (!TriggerHelperClass.hasAlreadyfired())
    {system.debug('in inset'+TriggerHelperClass.hasAlreadyfired());
        if(trigger.isInsert)
    {  
    for(Competing_Customer__c obj:trigger.new)
        {
          
        Competing_Customer__c[] comp=[select Account__c,Account_competitor__c from Competing_Customer__c where Account__c = :obj.account__c AND Account_competitor__c = :obj.Account_competitor__c];
      if (comp.size() > 0 )
      {
          system.Debug('in if');     
          obj.adderror('this is a duplicate entry');
      }
            else{
       system.debug('step');
                system.debug('in else');
           newcompetitor.add(obj);
            }
        }
   
    for(integer i=0;i<newcompetitor.size();i++)
        {

        competitor.Account__c=newcompetitor[i].Account_competitor__c;
        competitor.Account_competitor__c=newcompetitor[i].account__c;
        TriggerHelperClass.setAlreadyfired();
     
            competitorlist.add(competitor);
        }
  insert competitorlist;
       
    }
   
    }
    if(trigger.isDelete)
    {
        system.debug(TriggerHelperClass.hasAlreadyfired());
        if (!TriggerHelperClass.hasAlreadyfired())
            {
    for(Competing_Customer__c obj:trigger.old)
        {
            newcompetitor.add(obj);
        }
           
                try{
                for(integer i=0;i<newcompetitor.size();i++)
        {
        competitor=[select id from Competing_Customer__c where Account__c = :newcompetitor[i].Account_competitor__c AND Account_competitor__c = :newcompetitor[i].Account__c];
                competitorlist.add(competitor);
                TriggerHelperClass.setAlreadyfired();
            }
       
               
                delete competitorlist;}
                catch(exception e)
                {system.debug('catch error');}
    }
       
}
}
Hi,
I have written the below trigger to update the campaign member status. But its not working and i am not able to figure out why
Thanks for help in advance.

trigger UpdateCampaignStatus on FeedBack__c (after insert,after update) {
    try{
    set<id> fid=new set<id>();
    for(feedback__c fb:trigger.new)
    {
        if(fb.recordtypeid=='01250000000UNZH')
        {
            list <CampaignMember> cm=[select id,status from CampaignMember where contactid=:fb.contact__c and campaignid=:fb.Campaign__c];
            cm[0].status='Completed';
            Update cm[0];
        }     
    }
    }catch(exception e)
    {
        system.debug(e.getmessage());
    }
        }
Hi,
 
i have the below requirement and i am new to visulaforce. Someone please provide an idea on how to create this.

I want to create a table with all the picklist values available. when i add this VF page to page layout, the corresponding picklist value for that record should be highlighted in my table, Like the image below --
User-added image
Thanks for your help in advance.
Hi,
Please help me with this requirement

I have 'score' field on objectA and this object has lookup relationship to account.
I want to take average of 'score' field on all objectA records created in current quarter and stamp that value on account.


Thanks in advance
I have a competitor object. It has lookup and Master-detail relationship to Account Object. When i try to mass insert records, I get the follwing error
"autoinsertforcompetitor: execution of BeforeInsert caused by: System.ListException: Before Insert or Upsert list must not have two identically equal elements Trigger.autoinsertforcompetitor: line 48, column 1"

Here's my code

trigger autoinsertforcompetitor on Competing_Customer__c (before insert,after delete)
{
         list<Competing_Customer__c> newcompetitor=new list<Competing_Customer__c>();
     list<Competing_Customer__c> competitorlist=new list<Competing_Customer__c>();
     Competing_Customer__c competitor = new Competing_Customer__c();
   
    if (!TriggerHelperClass.hasAlreadyfired())
    {system.debug('in inset'+TriggerHelperClass.hasAlreadyfired());
        if(trigger.isInsert)
    {  
    for(Competing_Customer__c obj:trigger.new)
        {
          
        Competing_Customer__c[] comp=[select Account__c,Account_competitor__c from Competing_Customer__c where Account__c = :obj.account__c AND Account_competitor__c = :obj.Account_competitor__c];
      if (comp.size() > 0 )
      {
          system.Debug('in if');     
          obj.adderror('this is a duplicate entry');
      }
            else{
       system.debug('step');
                system.debug('in else');
           newcompetitor.add(obj);
            }
        }
   
    for(integer i=0;i<newcompetitor.size();i++)
        {

        competitor.Account__c=newcompetitor[i].Account_competitor__c;
        competitor.Account_competitor__c=newcompetitor[i].account__c;
        TriggerHelperClass.setAlreadyfired();
     
            competitorlist.add(competitor);
        }
  insert competitorlist;
       
    }
   
    }
    if(trigger.isDelete)
    {
        system.debug(TriggerHelperClass.hasAlreadyfired());
        if (!TriggerHelperClass.hasAlreadyfired())
            {
    for(Competing_Customer__c obj:trigger.old)
        {
            newcompetitor.add(obj);
        }
           
                try{
                for(integer i=0;i<newcompetitor.size();i++)
        {
        competitor=[select id from Competing_Customer__c where Account__c = :newcompetitor[i].Account_competitor__c AND Account_competitor__c = :newcompetitor[i].Account__c];
                competitorlist.add(competitor);
                TriggerHelperClass.setAlreadyfired();
            }
       
               
                delete competitorlist;}
                catch(exception e)
                {system.debug('catch error');}
    }
       
}
}