• kkg
  • NEWBIE
  • 59 Points
  • Member since 2014
  • BS

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
I have Created Trigger on Opportunity which displays error message to the user if there is open task on Opportunity and user try to change the Stage value. It is working fine for this scenario but not for other if there is no open task present on opportunity and user try to change stage value and save the record it shows error as,

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Please Close Open Activities to update...".

Trigger is As
------------------------
trigger ShowErrorMsgOnOpportunity on Opportunity (before insert, before update) {

    List<Opportunity> newOppo = Trigger.new;
    
    try{
        List<Opportunity> countOpenTask = 
        [Select Id, Name, (Select Id, Status, WhoId From OpenActivities Where Status != 'Completed')OppoTask From Opportunity where Id IN: Trigger.new];
       
        for(Opportunity op : countOpenTask){
            if(op.OpenActivities.size() != 0){
              Trigger.newMap.get(op.Id).addError('Please Close Open Activities to update...');
            }   
        }
     }
     catch(Exception excep)
     {
         System.debug('Error='+excep);
     }  
}
Hi Friends,

I have enabled inline editor option from the customization settings but it is still not working. How to enable it again?
Hello All,

I need a test class for the below batch class.

global class batchJob implements Database.batchable<Sobject>{     
     String template;
     id oppId;
     id userId;
     global Database.QueryLocator start(Database.BatchableContext BC){
       Database.QueryLocator dq = Database.getQueryLocator([SELECT Name,Owner.email,StageName,id,RecordType.Name FROM Opportunity where (RecordType.Name='XXXX' OR RecordType.Name='YYY')         AND StageName <>'Funded' AND StageName <> 'Lost']);
       return dq;
    } 
    global void execute(Database.BatchableContext info, List<Sobject> scope){
        List<Opportunity> optysToUpdate = new List<Opportunity>();
        LIST<String> ccList=new LIST<String>();
        LIST<String> recipientList=new LIST<String>();
        Map<Id,String> userEmail=new Map<Id,String>();
       Risk_Approved_Remainder_Notification__c XXXRT = Risk_Approved_Remainder_Notification__c.getValues('XXX');
       Risk_Approved_Remainder_Notification__c YYYRT = Risk_Approved_Remainder_Notification__c.getValues('YYY');  
        If(scope.size()>0){
        for(Sobject l : scope){
          Opportunity optyRec= (Opportunity)l;
         system.debug('Execute methode optyrecords is : '+optyRec);
          if(XXXRT.RTValue__c.equals(optyRec.RecordType.Name) && optyRec.DAM_Approved_Counter__c > Integer.valueOf(XXXRT.ReminderDays__c.round())){
                  if(optyRec.Mail_Sent_Flag__c!=true){
                   ccList.add(optyRec.Owner.email);
                   recipientList.add(optyRec.OwnerId); 
                   template=XXXRT.Email_Template_Id__c;
                   oppId=optyRec.Id;
                   userId=optyRec.OwnerId;
                   userEmail.put(userId,optyRec.Owner.email);
                   EmailUtility.sendEmailMessage(ccList,recipientList,template,oppId,userEmail); 
                   optyRec.Mail_Sent_Flag__c=true; 
                   optysToUpdate.add(optyRec); 
                }
           } 
          else if(YYYRT.RTValue__c.equals(optyRec.RecordType.Name) && optyRec.DAM_Approved_Counter__c > Integer.valueOf(YYYRT.ReminderDays__c.round())){
                if(optyRec.Mail_Sent_Flag__c!=true){
                   ccList.add(optyRec.Owner.email);
                   recipientList.add(optyRec.OwnerId); 
                   template=YYYRT.Email_Template_Id__c;
                   oppId=optyRec.Id;
                   userId=optyRec.OwnerId;
                   userEmail.put(userId,optyRec.Owner.email);
                   EmailUtility.sendEmailMessage(ccList,recipientList,template,oppId,userEmail); 
                   optyRec.Mail_Sent_Flag__c=true;
                   optysToUpdate.add(optyRec);
                }
            }  
        } 
      }
      update optysToUpdate;
    }     
    global void finish(Database.BatchableContext info){  
        
    } 
}


Please help me out on this. please write a test class for that class...!!!

 
  • July 16, 2015
  • Like
  • 0
How to know repository size of the information "XXX_Business " holds within salesforce? (An approximate number would be acceptable).
  • May 25, 2015
  • Like
  • 0
Hello Friends,

Please help me it's Urgent ....

Thanks for your help in advance..
  • May 13, 2015
  • Like
  • 0
Hello Friends,

I'm unable to get force.com metadata Components from my Org through Eclipses.

Please see the below Error Screen..

User-added image  

Please help me its urgent !!!!!
Thanks advance your help

 
  • May 05, 2015
  • Like
  • 0
Hello All,

### As per the salesforce governor limit lookup Relationship we can create upto 40 per Object.
 
Now my requirement is i want to create max 3 lookup Relationship , if i'm trying to create 4th lookup Relationship there should be a validation.

how to achive above requirement.?

Thank you for your help in advance !

 
  • April 16, 2015
  • Like
  • 0
1.We have Bucket filed on  Stage (plicklist) in Opportunity report.
2.We are categorized the values in stage (e.g: bucket names are A,B,C,D).
3.In Bucket A we have 4  stage pickvalues.
4. After runnig the report, One of the pickvalue in A bucket is shows like unbucket/other value.
            I am new to Bucket fileds, Please help on this...
  • November 05, 2014
  • Like
  • 0
I have Created Trigger on Opportunity which displays error message to the user if there is open task on Opportunity and user try to change the Stage value. It is working fine for this scenario but not for other if there is no open task present on opportunity and user try to change stage value and save the record it shows error as,

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Please Close Open Activities to update...".

Trigger is As
------------------------
trigger ShowErrorMsgOnOpportunity on Opportunity (before insert, before update) {

    List<Opportunity> newOppo = Trigger.new;
    
    try{
        List<Opportunity> countOpenTask = 
        [Select Id, Name, (Select Id, Status, WhoId From OpenActivities Where Status != 'Completed')OppoTask From Opportunity where Id IN: Trigger.new];
       
        for(Opportunity op : countOpenTask){
            if(op.OpenActivities.size() != 0){
              Trigger.newMap.get(op.Id).addError('Please Close Open Activities to update...');
            }   
        }
     }
     catch(Exception excep)
     {
         System.debug('Error='+excep);
     }  
}
How to know repository size of the information "XXX_Business " holds within salesforce? (An approximate number would be acceptable).
  • May 25, 2015
  • Like
  • 0
hi iam new to salesforce i have written some sample classes how can i debug those classes,pages and triggers. any documentation or videos is there please share
Hi Friends,

I have enabled inline editor option from the customization settings but it is still not working. How to enable it again?
1.We have Bucket filed on  Stage (plicklist) in Opportunity report.
2.We are categorized the values in stage (e.g: bucket names are A,B,C,D).
3.In Bucket A we have 4  stage pickvalues.
4. After runnig the report, One of the pickvalue in A bucket is shows like unbucket/other value.
            I am new to Bucket fileds, Please help on this...
  • November 05, 2014
  • Like
  • 0