• suresh beniwal 21
  • NEWBIE
  • 30 Points
  • Member since 2018
  • Certified Developer
  • Metacube software Pvt ltd.

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
create a custom object and it should have a field which is a lookup relation to Opportunity.  Create one more picklist field is Type__c(Category_A, Category_B, Category_C). three fields should created on Opportunity(Count of CategoryA,Count of CategoryB, Count of CategoryC). display the count of eachtype in the parent details record.
create a custom object and it should have a field which is a lookup relation to Opportunity.  Create one more picklist field is Type__c(Category_A, Category_B, Category_C). three fields should created on Opportunity(Count of CategoryA,Count of CategoryB, Count of CategoryC). display the count of eachtype in the parent details record.
when ever account type is changed form any value to 'Customer' need to 
send an email to account owner saying your account become customer 
and create a task and assign it to account owner.
hi All,
 my batch is given below:-
public class BatchZendeskToSalesforce implements Database.Batchable<sObject>{
     public Database.querylocator start(Database.BatchableContext BC){
          string query;
         
         query = 'SELECT Id, Name,url__c,External_Id__c,'+
             'Group_Id__c,Shared_Tickets__c,'+
             'Shared_Comments__c,phone,Domain_Name__c,Notes__c,'+
             'Payroll_Vault__c,Zendesk_Id__c,Details__c ' +
             'FROM Account ';
         return Database.getQueryLocator(query);
    }
     public void execute(Database.BatchableContext BC, List<Account> Accounts){
        
        Set<Id> accountIds = new Set<Id>();
        for( Account acc : Accounts ){
           accountIds.add( acc.Id );   
        }
        getAccounts();
    }
    
    public static List<Account> getAccounts(){

        HttpRequest req = new HttpRequest();
        req.setMethod( 'GET' );
        String username = 'kevin@sfdcconsultants.com';
        String password = '45j2JpHB^qy*';
        Blob headerValue = Blob.valueOf( username + ':' + password );
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode( headerValue );
        req.setHeader( 'Authorization', authorizationHeader );
        req.setHeader( 'Content-Type', 'application/json' );
        req.setEndpoint( 'https://timerack.zendesk.com/api/v2/organizations.json' );
        Http binding = new Http();
        HttpResponse res = binding.send( req );
        
        Map<String, Object> results = ( Map<String, Object> )JSON.deserializeUntyped( res.getBody() );
        List<Object> lstOrganizations = ( List<Object> )results.get( 'organizations' );
        List<Map<String, Object>> customerAtt = new List< Map< String, Object >>();
        for ( Object customer : lstOrganizations ) {
            Map<String, Object> customerAttributes = ( Map< String, Object >)customer;
            customerAtt.add( customerAttributes );
        }
        List< Account > listAccountToUpsert = new List< Account >();
        for( Map< String, Object> attMap : customerAtt ){
            Account acc = new Account();
            String fullName = String.valueOf( attMap.get( 'name' ));
           /* if( fullName.split(' ').size() > 1 ){
                ct.FirstName = fullName.substring( 0, fullName.indexOf(' ') );
                ct.LastName = fullName.substring( fullName.indexOf(' ') + 1 );
            }else{
                ct.LastName = fullName;
            }*/
            //ct.email = String.valueOf( attMap.get( 'email' ));
            acc.url__c =  String.valueOf( attMap.get( 'url' ));
            acc.External_Id__c = String.valueOf( attMap.get( 'external_id' ));
            acc.Group_Id__c = String.valueOf( attMap.get( 'group_id' ));
            acc.Shared_Tickets__c = Boolean.valueOf( attMap.get( 'shared_tickets' ));
            acc.Shared_Comments__c = Boolean.valueOf( attMap.get( 'shared_comments' ));
            acc.phone = String.valueOf( attMap.get( 'phone' ));
            acc.Domain_Name__c = String.valueOf( attMap.get( 'domain_names' ));
            acc.Notes__c = String.valueOf( attMap.get( 'notes' ));
            acc.Payroll_Vault__c = String.valueOf(attMap.get('payroll_vault'));
            acc.Zendesk_Id__c = String.valueOf( attMap.get( 'id' ));
            acc.Details__c = String.valueOf(attMap.get('details'));
            
            //ct.Zendesk_Parent_Organisation_Id__c = String.valueOf( attMap.get( 'organization_id' ));
            listAccountToUpsert.add(acc);
            /*if(ct.Name == 'testBC'){
                System.assert(false, listAccountToUpsert);
            }*/
        }
        return listAccountToUpsert;
 }
     public void finish(Database.BatchableContext BC){
        
    }
}
when i run the batch its showing me error:- too many callouts
how to solve this error?
Any suggestions?