+ Start a Discussion

Batch Apex getting error like: Illegal assignment from String to Boolean while updating field


Iam getting error like: Illegal assignment from String to Boolean

isActive is CheckBox type custome field, while creating record it self we check isActive field to true, now i want to unCheck(false).

Global class unCheckisActive implements database.Batchable<sObject>{
    global database.QueryLocator start(database.BatchableContext BC){
    String query='Select id,isActive__c,LastModifiedDate From object__c Where LastModifiedDate >Last_N_Years:1';
    return database.getQueryLocator(query);
    global Void execute(database.BatchableContext BC, List<object__c> scope ){
        List<object__c> objectToUpdate=new List<object__c>();
        for(object__c obj:scope){
            obj.isActive__c='False'; // Illegal assignment from String to Boolean
        update objectToUpdate;
    global void finish(database.BatchableContext BC){

Kindly suggest me how to rectify this error.

Thanks in advance!!!
Shaijan ThomasShaijan Thomas
obj.isActive__c=False;  // remove the '  '
SF AdminSF Admin


 // anything written between quotes(' ') is considered as string. 

try obj.isActive__c=False; instead of obj.isActive__c='False';


Thanks for your support Shaijan and Rizvan.