• Sreenu Reddy 16
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies
sfdc flocks can you give me  help on below code .

Method does not exist or incorrect signature: void put(Decimal, String) from the type Map<Id,String> at line 8 column 24

trigger changeowner on Lead (before insert) {
     Map<Id,String> zipCodeUserMap = new Map<Id,String>();
     List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
     zipCodes = [Select id,ZipCode__c,Counserlor__c  from Zip_Code__c];
      
      for (Zip_Code__c zc :zipCodes){
        
        zipCodeUserMap.put(zc.ZipCode__c,zc.Counserlor__c);   
     }
       
       
       
       for(Lead l : Trigger.new) 
       {
        if(zipCodeUserMap.containsKey(l.Zip_Code__c)) 
        {
            l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
        }
       }
}

hi viewers: i have two fields in task obj most recent campaign (lookup to campaign)  and description , i want to update the description  as mosot resend campaign (lookup to campaign ) in task.. using before trigger. i wrote some logic  updateDescription on Task (Before insert,Before Update) . i am getting fallowing error when i am create record. any one help me .


{

            set<id> setcmpnid =new set<id>();
            
            for(task tsk:trigger.new)
              {
                String wId = tsk.WhatId;
                
                if(wId!=null && !setcmpnid.contains(tsk.WhatId))
                { 
                  setcmpnid.add(tsk.WhatId);
                  system.debug('++++++ the setcmpnid  value is +++++++'+setcmpnid);
                } 
            }
            
            if(setcmpnid.size()>0) {
            
            list<campaign> tskcmpn= [Select id, Description from campaign where id in :setcmpnid ];
            
            Map<id,campaign> cmpn= new Map<id,campaign>();
               for(campaign cpn : tskcmpn)
              {
                  cmpn.put(cpn.Id,cpn); 
                   system.debug('++++++ the campaign id value is +++++++'+cmpn);
              }
            
              for (task tsk:trigger.new) {
                                
                String wId = tsk.WhatId; 
            
               if(wId!=null) { 
                  
               campaign thiscpn = cmpn.get(tsk.WhatId);  
               
               if(thiscpn != null){
               
               tsk.most_Resent_Campaign__c = thiscpn.Description;
            
               system.debug('++++++ the tsk.most_Resent_Campaign__c value is +++++++'+tsk.most_Resent_Campaign__c);
               
                  }            
                }       
            
              }
            
            }
         }
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger updateDescription caused an unexpected exception, contact your administrator: updateDescription: execution of BeforeUpdate caused by: System.StringException: Invalid id: sfdc salesforce sfdc : Trigger.updateDescription: line 37, column 1
HI Viewers,
i have two  fields   converteddate__C(Date) and submittedDate__c(Date/Time)  in lead object and having  formula field Duration scince converted.Here "Dutation_since_converted =  converteddate__C - Datevalue(submittedDate__c) "..  i want  calculate only weekdays. i write a formula , i am getting  duration_since_converted. But i want exclude weeends in this ?How to wrt formula for exclude weekends can any one can help me please .

Thanks!
Sreeni sree
Hi Viewers,

i want sent email when click on detail page custom button in opportunity obj. &update the fields 
1. send an email partner
2.channel manager(account owner of partner account)
3.account owner
4. fields should be updated like date= today,stage='duplcate',status= 'rejected'.


​can any one help me .
sfdc flocks can you give me  help on below code .

Method does not exist or incorrect signature: void put(Decimal, String) from the type Map<Id,String> at line 8 column 24

trigger changeowner on Lead (before insert) {
     Map<Id,String> zipCodeUserMap = new Map<Id,String>();
     List<Zip_Code__c> zipCodes = new List<Zip_Code__c>();
     zipCodes = [Select id,ZipCode__c,Counserlor__c  from Zip_Code__c];
      
      for (Zip_Code__c zc :zipCodes){
        
        zipCodeUserMap.put(zc.ZipCode__c,zc.Counserlor__c);   
     }
       
       
       
       for(Lead l : Trigger.new) 
       {
        if(zipCodeUserMap.containsKey(l.Zip_Code__c)) 
        {
            l.Ownerid = zipCodeUserMap.get(l.Zip_Code__c);
        }
       }
}

hi viewers: i have two fields in task obj most recent campaign (lookup to campaign)  and description , i want to update the description  as mosot resend campaign (lookup to campaign ) in task.. using before trigger. i wrote some logic  updateDescription on Task (Before insert,Before Update) . i am getting fallowing error when i am create record. any one help me .


{

            set<id> setcmpnid =new set<id>();
            
            for(task tsk:trigger.new)
              {
                String wId = tsk.WhatId;
                
                if(wId!=null && !setcmpnid.contains(tsk.WhatId))
                { 
                  setcmpnid.add(tsk.WhatId);
                  system.debug('++++++ the setcmpnid  value is +++++++'+setcmpnid);
                } 
            }
            
            if(setcmpnid.size()>0) {
            
            list<campaign> tskcmpn= [Select id, Description from campaign where id in :setcmpnid ];
            
            Map<id,campaign> cmpn= new Map<id,campaign>();
               for(campaign cpn : tskcmpn)
              {
                  cmpn.put(cpn.Id,cpn); 
                   system.debug('++++++ the campaign id value is +++++++'+cmpn);
              }
            
              for (task tsk:trigger.new) {
                                
                String wId = tsk.WhatId; 
            
               if(wId!=null) { 
                  
               campaign thiscpn = cmpn.get(tsk.WhatId);  
               
               if(thiscpn != null){
               
               tsk.most_Resent_Campaign__c = thiscpn.Description;
            
               system.debug('++++++ the tsk.most_Resent_Campaign__c value is +++++++'+tsk.most_Resent_Campaign__c);
               
                  }            
                }       
            
              }
            
            }
         }
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger updateDescription caused an unexpected exception, contact your administrator: updateDescription: execution of BeforeUpdate caused by: System.StringException: Invalid id: sfdc salesforce sfdc : Trigger.updateDescription: line 37, column 1
Hi Viewers,

i want sent email when click on detail page custom button in opportunity obj. &update the fields 
1. send an email partner
2.channel manager(account owner of partner account)
3.account owner
4. fields should be updated like date= today,stage='duplcate',status= 'rejected'.


​can any one help me .
Batch class as exposed as interface implement by developer.it is helpful for handle large number of records.Please explain real time exmple why we need to use Batch class  in real time?
public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
}
//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2) {
//check for date2 being in the past
if( date2 < date1) { return false; }
//check that date2 is within (>=) 30 days of date1
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 >= date30Days ) { return false; }
else { return true; }
}
//method to return the end of the month of a given date
private static Date SetEndOfMonthDate(Date date1) {
Integer totalDays = Date.daysInMonth(date1.year(), date1.month());
Date lastDay = Date.newInstance(date1.year(), date1.month(), totalDays);
return lastDay;
}
}

I need test class for this class.Please provide me
Hello developer heroes!

I'm working through the Apex modules on Trailhead and can't seem to get past this one: https://developer.salesforce.com/en/trailhead/force_com_programmatic_beginner/apex_triggers/apex_triggers_bulk.

Hopefully this doesn't read like a 'please complete the course for me' kinda post, but I have written a trigger that I believe meets the criteria but it isn't passing the check, so I wanted to seek the guidance of the experts.

The challenge is to do this:

Create an Apex trigger for Opportunity that adds a task to any opportunity set to 'Closed Won'.

To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.The Apex trigger must be called 'ClosedOpportunityTrigger'

- With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
- To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
- This challenge specifically tests 200 records in one operation.


And here is the trigger I have come up with, which compiles OK and stands up to a manual (though admittedly unbulkified) test:
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();
    
    for (Opportunity opp : [SELECT Id, StageName FROM Opportunity WHERE StageName = 'Closed Won' AND Id IN :Trigger.new]){
                    
            taskList.add(new Task(Subject = 'Follow Up Test Task',
                                  WhatId = opp.Id));
       
    }

    if(taskList.size()>0){
        
        insert taskList;
        
    }
    
}
I have tried replacing the SOQL with a straightforward 'for (Opportunity opp : Trigger.new)' and having the taskList.add inside an IF that checks for Closed Won - no luck. I also thought about checking to see if the stage was being changed to Closed Won, rather than the trigger firing on every edit, but I don't think this is what the module is asking for.

Where do you think I'm going wrong?

Huge thanks in advance!