You need to sign in to do that
Don't have an account?

Update Task datetime field from a custom field
Hello all,
I'm working on a trigger that assigns a time specific task to an object I call subject. Here is what I have so far:
trigger CreateBloodDrawTasks on Blood_Draw__c (after insert) {
for(Blood_Draw__c c1:trigger.new){
List<Subject__c> c2=[select id,Trial__c from Subject__c where Trial__c=:c1.Trial__c];
list<task> tasklist=new list<task>();
for(Subject__c c2a:c2){
Task tsk=new Task();
tsk.WhatId=c2a.id;
tsk.Subject='Blood Draw - ' + c1.Name + ' hrs';
tsk.activitydate = c1.Dosing_Start__c;
tasklist.add(tsk);
}
insert tasklist;
}
}
This generates the following Error: Compile Error: Invalid field Dosing_Start__c for SObject Blood_Draw__c at line 9 column 32
I'm not sure what's causing this as both fields are already in the date/time format. Does anyone have any ideas?
Thanks!
John
I'm working on a trigger that assigns a time specific task to an object I call subject. Here is what I have so far:
trigger CreateBloodDrawTasks on Blood_Draw__c (after insert) {
for(Blood_Draw__c c1:trigger.new){
List<Subject__c> c2=[select id,Trial__c from Subject__c where Trial__c=:c1.Trial__c];
list<task> tasklist=new list<task>();
for(Subject__c c2a:c2){
Task tsk=new Task();
tsk.WhatId=c2a.id;
tsk.Subject='Blood Draw - ' + c1.Name + ' hrs';
tsk.activitydate = c1.Dosing_Start__c;
tasklist.add(tsk);
}
insert tasklist;
}
}
This generates the following Error: Compile Error: Invalid field Dosing_Start__c for SObject Blood_Draw__c at line 9 column 32
I'm not sure what's causing this as both fields are already in the date/time format. Does anyone have any ideas?
Thanks!
John
Hello, John, two possibilities come to mind for why you're seeing the error.
I think the Task.ActivityDate is actually a Date field. Did you try to convert the Dosing_Start__c to a Date field (like this Date.valueOf(c1.Dosing_Start__c))?
tsk.activitydate = Date.valueOf(c1.Dosing_Start__c);
Unfortunatley it's still churning out the same error: Compile Error: Invalid field Dosing_Start__c for SObject Blood_Draw__c at line 9 column 45