• Shanmuga Prasath Pushpanathan
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Getting this below error :
'System.CalloutException: Web service callout failed: Unable to find header type info fortokenRes'
When I tried to schedule batch apex, I got error saying that Contructor is not defined so i have created the scheduler apex 

Batch apex :
global class batchclass implements Database.Batchable<sObject>{

    Set<Id> accountIdSet = new Set<Id>();

    global batchclass(Set<Id> accountIdSet){
        if(accountIdSet != null){
            this.accountIdSet= accountIdSet;
        }
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
        
        return Database.getQueryLocator('SELECT Id, Region__c,'+
                                     'FROM Account '+
                                     'Where Id IN: accountIdSet');
        
    }

    global void execute(Database.BatchableContext BC, List<SObject> scope) {
        //logic
    }

    global void finish(Database.BatchableContext BC) {
        //doing nothing
    }

}

Sheduler apex : 
global class Schedulerapex implements Schedulable {
    
   Set<Id> accntSet = new Set<Id>();
    
   //constructor
    global batchclass(Set<Id> accountIdSet){
        
        accntSet = accountIdSet;
        
    } 
    
   global void execute(SchedulableContext sc) {
      batchclass updateAccountBatch = new batchclass(accntSet); 
      database.executebatch(updateAccountBatch, 1000);
   }
}

In this scheduler apex how to pass the accountIdSet?
Do we need to query the account in the scheduler apex for passing the parameter to batch class?
I have implemented the below code which is working fine, but client want simpler code without cmplexity like using the inputfield tag 
Controller : 
public String selectedpicklistvalue{get; set;}
public List<selectOption> getpicklistvalue() {
        List<SelectOption> picklistvalue= new List<SelectOption>();
        Schema.DescribeFieldResult picklistvalueResult = customobject__c.picklist_field__c.getDescribe();
        List<Schema.PicklistEntry> replace = picklistvalueResult .getPicklistValues();
        picklistvalue.add(new SelectOption('',label.None_for_Picklist));
        for( Schema.PicklistEntry r : replace) {
            picklistvalue.add(new SelectOption(r.getLabel(), r.getValue()));
        }
        return picklistvalue;
     }

VF page : 
<apex:selectList id="selectedpicklistvalue" value="{!selectedpicklistvalue}" label="Picklist Value" size="1">
                <apex:selectOptions value="{!picklistvalue}"> 
                </apex:selectOptions>
                </apex:selectList>
While covering the below batch apex im getting a error 'System.UnexpectedException: Start did not return a valid iterable object.'

I exected the batch class like:
batchClass b = new batchClass(idSet, stringMap);
Database.executeBatch(b,1);

Batch class:    
global class batchClass implements Database.Batchable<sObject>{

        Set<Id> idSet = new Set<Id>();
        Map<String, String> stringMap = new Map<String, String>();
        
        public batchClass(Set<Id> idSet, Map<String, String> stringMap){
            this.idSet = idSet ;
            this.stringMap = stringMap;
        }
        
        global Database.QueryLocator start(Database.BatchableContext BC){         
                String query = 'Query';
                return Database.getQueryLocator(query);
            }

        global void execute(Database.BatchableContext BC, List<sObject> scope) {
             //logic
        }
        
        global void finish(Database.BatchableContext BC) {}
        
    }

 
I have implemented the below code which is working fine, but client want simpler code without cmplexity like using the inputfield tag 
Controller : 
public String selectedpicklistvalue{get; set;}
public List<selectOption> getpicklistvalue() {
        List<SelectOption> picklistvalue= new List<SelectOption>();
        Schema.DescribeFieldResult picklistvalueResult = customobject__c.picklist_field__c.getDescribe();
        List<Schema.PicklistEntry> replace = picklistvalueResult .getPicklistValues();
        picklistvalue.add(new SelectOption('',label.None_for_Picklist));
        for( Schema.PicklistEntry r : replace) {
            picklistvalue.add(new SelectOption(r.getLabel(), r.getValue()));
        }
        return picklistvalue;
     }

VF page : 
<apex:selectList id="selectedpicklistvalue" value="{!selectedpicklistvalue}" label="Picklist Value" size="1">
                <apex:selectOptions value="{!picklistvalue}"> 
                </apex:selectOptions>
                </apex:selectList>