Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- getting error:Loop variable must be of type SObjec...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
getting error:Loop variable must be of type SObject at line 9 column 16
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 12:03 AM
public class UpdateTask{ public static Boolean stopDup = false;
public void insertRootCause(List<Task__c> lstTask)
{
set<Id> Ids=new set<Id>();
map<id,id> mapparent=new map<id,id>();
//for(Task__c tsk:trigger.new)
{ //ids.add(tsk.Project__c);}
for(project__c prj: trigger.new) // getting error here..please help as why this error is comimg..I'm trying to get parent's field value here which will be paste in the child of this object
{
mapParent.put(prj.id, prj.Dev_Lead_User__c);
}
if(!stopDup){
List<Root_cause__c> lstRC=new List<Root_Cause__c>();
for(Task__c t:lstTask){
// Project__c project = prj.get(t.project__c);
Root_Cause__c RCDel= new Root_Cause__c();
System.debug('Im Inside 123----->'+t);
RCDel.TaskName__c=t.Id;
system.debug(t.TQL_Phase__c=='6.Launch');
RCDel.Date__c=System.Today();
RCDel.Launch_Date_Delay__c=0;
RCDel.Task_Delay__c=0;
RCDel.Dev_Lead__c= mapParent.get(t.Project__c);
lstRC.add(RCDel);
}
if(lstRC.size()>0){
insert lstRC;
stopDup = true;
}
}
}
}
Re: getting error:Loop variable must be of type SObject at line 9 column 16
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 12:52 AM
You can't use trigger.new as you aren't in a trigger, you are in an instance of a class.
If this method is being called from a trigger you'll need to pass trigger.new as a parameter to the method.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: getting error:Loop variable must be of type SObject at line 9 column 16
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 02:00 AM
thanks for the reply..i have modified my code and it looks something like this now..
public class UpdateTask{
public static Boolean stopDup = false;
public void insertRootCause(List<Task__c> lstTask){
List<project__c> lstprj=new List<project__C>();
set<Id> Ids=new set<Id>();
map<id,id> mapparent=new map<id,id>();
for(Task__c tsk:lsttask){
ids.add(tsk.Project__c);}
lstprj=[select id,Dev_Lead_User__c from project__c where id in :Ids];
map<Id,Project__c> map1=new map<id,project__c>();
for(Task__c t:lsttask){
mapparent.put(t.project__c,t.id);}
for(project__c prj:lstprj){
map1.put(prj.id,prj);
}
if(!stopDup){
List<Root_cause__c> lstRC=new List<Root_Cause__c>();
for(Task__c t:lstTask){
// Project__c project = prj.get(t.project__c);
Root_Cause__c RCDel= new Root_Cause__c();
System.debug('Im Inside 123----->'+t);
RCDel.TaskName__c=t.Id;
system.debug(t.TQL_Phase__c=='6.Launch');
RCDel.Date__c=System.Today();
RCDel.Launch_Date_Delay__c=0;
system.debug(RcDEl.Launch_Date_Delay__c==0);
RCDel.Task_Delay__c=0;
RCDel.Dev_Lead__c= map1.get(mapparent.get(t.id)).Dev_Lead_user__c;
lstRC.add(RCDel);
}
if(lstRC.size()>0){
insert lstRC;
stopDup = true;
}
}
}
}
Re: getting error:Loop variable must be of type SObject at line 9 column 16
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 02:02 AM
Re: getting error:Loop variable must be of type SObject at line 9 column 16
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-05-2013 02:19 AM
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.

