• Andrew Wilkinson 2
  • NEWBIE
  • 40 Points
  • Member since 2015
  • Technical Architect/Senior Developer
  • Levementum

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
I'm sure this is a very novice question, but is there a way to require an attachment on a form before allowing the user to select a field picklist value of closed won?
I was wondering if it was possible to create a workflow for an automation email to a checkbox field when it is changed (Checked/ Unchecked)
global class customerbatch implements Database.Batchable<sobject>
{
    public String myname;
    global customerbatch(String myname)
    {
        this.myname=myname;
    }
    global Database.QueryLocator start(Database.BatchableContext bc)
    {
        return Database.getQueryLocator('select id,AType__c from Customer__C where name='+myname);
    }
    global void execute(Database.BatchableContext bc,list<customer__c> scope)
    {
        list<Customer__c> cust=new List<Customer__c>();
        for(Customer__c c:cust)
        {
            c.AType__c='saving';
            cust.add(c);
        
        }
        update cust;
    }
        global void finish(Database.BatchableContext bc)
        {
            Messaging.singleEmailMessage myemail=new Messaging.singleEmailMessage();
            String[] toadd=new String[]{'penchalaraju7@gmail.com'};
            myemail.setToAddresses(toadd);
            myemail.setSubject('my notification');
            messaging.sendEmail(new messaging.Email[]{myemail});
            
        }
    
}

 
I'm sure this is a very novice question, but is there a way to require an attachment on a form before allowing the user to select a field picklist value of closed won?
I have a requirement to retrieve a selected user's calendar on a visualforce page. Can anyone help ?
this is my trigger
trigger limitrecordtypes on Evaluation_by_metric__c (before insert,before update) {


if(trigger.isinsert){


list<Evaluation_by_metric__c> recordset=new list<Evaluation_by_metric__c>([select id,recordtypeid,Quarter__c,Metric__c,Month__c from Evaluation_by_metric__c]);


 for(Evaluation_by_metric__c c: trigger.new)
 {
   //mapping close period record with evaluation record before insert
   c.Close_Period__c = [select id from Close_Period__c limit 1].id;
   system.debug('look '+c.Close_Period__c);
   
   if(c.Quarter__c != null)
   {
    for(Evaluation_by_metric__c cv: recordset)
       {
        if(cv.Quarter__c == c.Quarter__c && cv.recordtypeid == c.recordtypeid && cv.Metric__c==c.Metric__c)
         {
          c.Quarter__c.adderror('This Recordtype has been created for this Quarter');
         }
   }
 }
  if(c.Month__c != null)
      {
        for(Evaluation_by_metric__c ebm : recordset)
         {
            if(ebm.Month__c == c.Month__c && ebm.recordtypeid == c.recordtypeid && ebm.Metric__c==c.Metric__c)
              {
            c.Month__c.adderror('This Recordtype has been created for this Month');
              }
         }
      }
  }
 
 }
 
 
if(trigger.isupdate)
{
  list<Evaluation_by_metric__c> recordset1=new list<Evaluation_by_metric__c>([select id,recordtypeid,Quarter__c,Metric__c,Month__c from Evaluation_by_metric__c]);


 for(Evaluation_by_metric__c c: trigger.new){
 
    //mapping close period record with evaluation record before insert
   c.Close_Period__c = [select id from Close_Period__c limit 1].id;
   
 Evaluation_by_metric__c oldAsset=trigger.oldMap.get(c.id);
 system.debug('@@@@@@'+oldAsset);
 
     if(oldAsset.Quarter__c !=null){
 
         for(Evaluation_by_metric__c cv: recordset1){
 
             if(cv.Quarter__c == oldAsset.Quarter__c && cv.recordtypeid == oldAsset.recordtypeid && cv.Metric__c==oldAsset.Metric__c){
             
               cv.quarter__c=oldAsset.Quarter__c;
               cv.recordtypeid = oldAsset.recordtypeid;
               cv.Metric__c=oldAsset.Metric__c;
              
               
                 
 }
 else if(cv.Quarter__c == c.Quarter__c && cv.recordtypeid == c.recordtypeid && cv.Metric__c==c.Metric__c){
 
                 c.Quarter__c.adderror('This Recordtype has been created for this Quarter');
 
 }
 }
 
 
 }
 
 
 
 if(oldAsset.Month__c != null){
 for(Evaluation_by_metric__c ebm: recordset1){
 if(ebm.Month__c == oldAsset.Month__c && ebm.recordtypeid == oldAsset.recordtypeid && ebm.Metric__c==oldAsset.Metric__c){
               ebm.Month__c =oldAsset.Month__c;
               ebm.recordtypeid = oldAsset.recordtypeid;
               ebm.Metric__c=oldAsset.Metric__c;
}
 else if(ebm.Month__c == c.Month__c && ebm.recordtypeid == c.recordtypeid && ebm.Metric__c==c.Metric__c){
 
                 c.Month__c.adderror('This Recordtype has been created for this Quarter');
 
 }
}
}
}










}
}

and i got only 13% test coverage for test class
@isTest

private class limitrecordtypesTest{

    
   static testMethod void lim() {
   
   
   Boolean result = false;
   recordtype rec=new recordtype();
   rec.name='Financial evaluation';
  
   Metric__c met1=new  Metric__c(Name='a');
    Metric__c met2=new  Metric__c(Name='b');
    Evaluation_by_metric__c eva1 = new Evaluation_by_metric__c(Metric__c=met1.id,Quarter__c='Q1',recordtype=rec); 
    
   insert eva1;
   
    Evaluation_by_metric__c eva3 = new Evaluation_by_metric__c(Metric__c=met2.id, Month__c='jan',recordtype=rec); 
    
   insert eva3;
   Close_Period__c closePeriod1 = new Close_Period__c(id=eva1.id,Name = 'Test1 Close Period');
     Close_Period__c closePeriod2 = new Close_Period__c(id=eva3.id,Name = 'Test2 Close Period');
        insert closePeriod1;
        insert closePeriod2;
   try{
   
    Evaluation_by_metric__c eva2 = new Evaluation_by_metric__c(Quarter__c='Q1',recordtype=rec); 
    insert eva2;
    }catch(DmlException ex){ result = true;}
      System.assert(result);
   
   
   try{
   
    Evaluation_by_metric__c eva4 = new Evaluation_by_metric__c(Month__c='jan',recordtype=rec); 
    insert eva4;
    }catch(DmlException ex){ result = true;}
      System.assert(result);
      }
      }

so,plz help me with the code.
I noticed a spike of api calls by one of the user in our Salesforce org. I wanted to understand that for the given user, can we get the source as in what app consumed these api calls under this user. So that i can know that what app on Salesforce is consuming these api and take a valid action to stop or reconfigure the source to use the api's.

Any help is appreciated!
Thanks
Can someone help me identify what is chewing up our API calls? As of 3 days ago, we started hitting our 20K limit every day, and prior to that we'd barely hit 1000. I've turned off all our coded integrations, and we're still hitting 20k. I looked at the SF reports, but they only tell me # of API calls by user. How can I see what the API calls are and where they are coming from to help me track down where the leak is???
  • March 14, 2015
  • Like
  • 2