You need to sign in to do that
Don't have an account?
Phuc Nguyen 18
Compile Error: Invalid loop variable type expected SObject
Hello,
Having an issue saving my class. getting
I am passing the parameters from another Class and I am trying to update a field on the Notice__c object with teh vatQueVatValue value
If you see any other issues with the batch class please also advise.
Cheers,
P
Having an issue saving my class. getting
Compile Error: Invalid loop variable type expected SObject was Notice__c
I am passing the parameters from another Class and I am trying to update a field on the Notice__c object with teh vatQueVatValue value
If you see any other issues with the batch class please also advise.
public class UpdateNoticeFromAccountQueueableBatch implements Database.Batchable <sObject>, Database.Stateful{ public List<Notice__c> noticeList = new List<Notice__c>(); public String vatQueVatValue; public UpdateNoticeFromAccountQueueableBatch ( List<Notice__c> records ,String vatValueFromQue ) { noticeList = records; vatQueVatValue = vatValueFromQue; system.debug('noticeList value in batch' + noticeList ); system.debug('vatQueVatValue value in batch' + vatQueVatValue ); } public List<SObject> start(Database.BatchableContext bc){ return noticeList; } public void execute(Database.BatchableContext bc, List<SObject> scope){ List< notice> NoticeToUpdateFromAccount = new List<Notice__c>(); system.debug('scope value ' + scope); system.debug('vatQueVatValue value batch' + vatQueVatValue); if(!scope.isEmpty()){ For ( Notice__c noticess : scope){ ---- Compile Error: Invalid loop variable type expected SObject was notice Notice__c noticess.Any_other_Lessor_Info_VAT_Number__c = vatQueVatValue; system.debug('notices.Any_other_Lessor_Info_VAT_Number__c ' + notices.Any_other_Lessor_Info_VAT_Number__c); } } Database.update(scope, false); } public void finish(Database.BatchableContext bc){ } }
Cheers,
P
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
on this line public void execute(Database.BatchableContext bc, List<SObject> scope){
Try replacing SObject with Notice__c
or
you can also try
replacing this line For ( Notice__c noticess : scope){
with for(Notice__c noticess :(List<Notice__c >) scope)
Try either of them.
If it helps mark it as best answer.
Thanks!
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
try below class and resolve your issue.
let me know if it helps you and don't forget to mark it as best answer.
Thank you
Abhinav I tried your example but it could not find the Any_other_Lessor_Info_VAT_Number__c field.
mukesh gupta I then tried your changes. This corrected the error and the update completed as required.
veer soni thank you for your time but since mukesh gupta example worked I stopped there.
Thansk again to the three of you for the help.
Cheers,
P