• dseiler
  • NEWBIE
  • 0 Points
  • Member since 2011
  • PARX


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi, my problem is this

ServiceAvailabililtyUpdaterForCase.HandleServiceAvailabilityChange does not handle Case(s) correctly, if there is no Setup defined in the Case.

Line:
Setup__c relatedSetup = [select Id, Name, Service_Availability__c, Cost_Center__c from Setup__c where Id =: c.Related_Setup__c];
Related_Setup__c is null (when the error occurs), so the situation when there is no Setup defined in the Case, should still be able to handle that Case.

 

global class ServiceAvailabililtyUpdaterForCase implements Schedulable,
                                                           Database.Stateful/*,
                                                           Database.Batchable<sObject>*/ {

    // Implement Schedulable interface function for entry function to schedule this batch
    global void execute(SchedulableContext sc){
        
        ServiceAvailabililtyUpdaterForCase updater = new ServiceAvailabililtyUpdaterForCase();
        Date currentDate = Date.newinstance(DateTime.Now().Year(), DateTime.Now().Month(), DateTime.Now().Day());          
        updater.HandleServiceAvailabilityChange(currentDate);     
    }    
  
  /*
  * Execute method of Batchable interface
  */
  global void execute( Database.BatchableContext BC, List<sObject> records ) {
      System.debug('ServiceAvailabililtyUpdaterForCase.execute batch');            
  }      
            
    public void HandleServiceAvailabilityChange(Date currentDate) {
      
      /*
      1) Fetch not closed Support Cases
      2) Fetch valid Service Availability objects per Case
      3) Sort SAs by a) Case b) Name
      4) Update last SA with duration until end of the month
      5) Create new SA from the beginning of the new month (with same Fault Classification)      
      */
      RecordType recordType = [select Id, Name from RecordType where SObjectType = 'Case' and Name = 'Support' LIMIT 1];
      
      System.Debug('SCHEDULED: SUPPORT CASE REC TYPE ID: ' + recordType.Id);            
                               
      List<Case> suppportCases = [select Id, Fault_Classification__c, Setup_Name__c, CaseNumber, Related_Setup__c,Status_Explanation__c 
                            from Case                                                       
                            where RecordTypeId =: recordType.Id
                            and IsClosed =: false                           
                            order by CreatedDate desc]; 

        System.Debug('SCHEDULED: SUPPORT CASE COUNT: ' + suppportCases.Size());      
      ServiceAvailability saHelper = new ServiceAvailability();
      
      // Setups that are already handled. We need to process each Setup only once.
      Set<Setup__c> alreadyHandled = new Set<Setup__c>();          
      
      for (Case c : suppportCases) {
        System.Debug('SCHEDULED: CASE ' + c.CaseNumber + ' HANDLING STARTED');
              
            List<Service_Availability__c> oldSAsPerCase = 
                                        [select Name, Status__c, Duration__c, Start_DateTime__c from Service_Availability__c                                                     
                                        where Case__c =: c.Id
                                        order by Name desc];
            
            System.Debug('SCHEDULED: OLD SA COUNT: ' + oldSAsPerCase.Size());
                                                    
            if (oldSAsPerCase.Size() > 0) {              
              Setup__c relatedSetup = [select Id, Name, Service_Availability__c, Cost_Center__c from Setup__c where Id =: c.Related_Setup__c];              
              
              Id hoursToUse = saHelper.GetHoursToUse(c, relatedSetup);                                            
              RecordType recordTypeIncident = [select Id, Name from RecordType where SObjectType = 'Service_Availability__c' and Name = 'Incident' LIMIT 1];
                
                System.debug('SCHEDULED: DATE IN LAST SA: ' + oldSAsPerCase[0].Start_DateTime__c);
                System.debug('SCHEDULED: CURRENT DATE: ' + DateTime.Now());

  

 

   

  • September 04, 2013
  • Like
  • 0

Hi,


we are using the migration tool and Ant for the deployment. Today I wanted to retrieve and deploy only Search Layouts for two custom objects. This should be possible as Search Layouts are a supported component type. That is what the documentation says (http://www.salesforce.com/us/developer/docs/daas/Content/daas_package.htm#component_types).

 

But in contrast to the documentation it was not possible to retrieve the Search Layouts for my custom object because the component type is not known to the meta data API:
[sf:retrieve] package.xml - Unknown entity:SearchLayouts

 

I also tried to list all components for that metadata type using <sf:listMetadata> but got a similar error message:
com.sforce.ws.SoapFaultException: INVALID_TYPE: Unknown type:SearchLayouts

 

At last I did a describe metadata types using <sf:describeMetadata> and found out that the component type SearchLayouts is not listed in the result file.

 

I did some tests for other 'supported component types' according to the documentation and found out that it's the same for the following types. They all are NOT supported:

  • Picklist
  • SearchLayouts
  • Weblink
  • and so on (you can check that out by your own)

 

It would be great if Salesforce could enable the functionality for all component types that are listed in the documentation. Or remove this types from the doc.

 

Thanks
Felix