• John Stamers
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies
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
Hi all,

I'm looking for some guidance on how I would go about writing a trigger that creates a task for a number of records. What I want to do is that when a new record is created under my object Blood_Draw a task is assigned to all of the records of another object Subjecct. Both the Blood_Draw and Subject objects have a child relationship with another object I have called Trial. The Blood_Draw records are each related to a trial so I would only want the subject records that are also related to the same trial to be updated.

Any help would be much appreciated!


Hi all, I have a trigger that will create a new record in my object "subject" when a certain field on another object "volunteer" is updated. However, I would also like the subject to become a child record for the volunteer. Can someone provide some guidance as to how I can alter my current trigger?

Trigger copyVolunteertoSubject on Volunteer__c(after insert, after update)
{
     List<Subject__c> sub=new List<Subject__c>();
     for(Volunteer__c v : Trigger.new)
     {
           if(v.Volunteer_Status__c == 'Screening Complete')
           {
                   Subject__c s=new Subject__c();
                   s.First_Name__c=v.First_Name__c;
                   s.Age__c=v.Age__c;
                   s.BMI__c=v.BMI__c;
                   s.City__c=v.City__c;
                   s.Country__c=v.Country__c;
                   s.Date_of_Birth__c=v.Date_of_Birth__c;
                   s.Email_Address__c=v.Email_Address__c;
                   s.Gender__c=v.Gender__c;
                   s.Height__c=v.Height__c;
                   s.Last_Name__c=v.Last_Name__c;
                   s.Phone_Number__c=v.Phone_Number__c;
                   s.Postal_code__c=v.Postal_code__c;
                   s.Province__c=v.Province__c;
                   s.Street_Address__c=v.Street_Address__c;
                   s.Weight__c=v.Weight__c;
                   s.Trial__c=v.Trial__c;
                   //add other fields of subject here and add volunteer values in that.
                
                   sub.add(s);
            }
            if(sub.size()>0)
            insert sub;
     }
}
Hi all,

I have a trigger which creates a new record under the object Subject__c when a certain criteria is met in another object Volunteer__c. The actual data contained within the Subject recrod will be identical to the Volunteer record. This is currently working but I also want the new subject record to become a child of another object called Trial__c. Does anyone have a suggestion on how to do this? Here is what my trigger currently looks like:

Trigger copyVolunteertoSubject on Volunteer__c(after insert, after update)
{
     List<Subject__c> sub=new List<Subject__c>();
     for(Volunteer__c v : Trigger.new)
     {
           if(v.Volunteer_Status__c == 'Screening Complete')
           {
                   Subject__c s=new Subject__c();
                   s.First_Name__c=v.First_Name__c;
                   s.Age__c=v.Age__c;
                   s.BMI__c=v.BMI__c;
                   s.City__c=v.City__c;
                   s.Country__c=v.Country__c;
                   s.Date_of_Birth__c=v.Date_of_Birth__c;
                   s.Email_Address__c=v.Email_Address__c;
                   s.Gender__c=v.Gender__c;
                   s.Height__c=v.Height__c;
                   s.Last_Name__c=v.Last_Name__c;
                   s.Phone_Number__c=v.Phone_Number__c;
                   s.Postal_code__c=v.Postal_code__c;
                   s.Province__c=v.Province__c;
                   s.Street_Address__c=v.Street_Address__c;
                   s.Weight__c=v.Weight__c;
                   s.Name=v.Name;
                   //add other fields of subject here and add volunteer values in that.
                
                   sub.add(s);
            }
            if(sub.size()>0)
            insert sub;
     }
}
Hi all, I want to preface this by saying I have absolutley zero knowledge of coding and how to write an apex trigger. However, I do know the result i'm trying to achieve so I'm hoping my description will be enough for someone to provide some help.

My situation is the following: I have 2 custom objects Volunteer and Subject. What I want to happen is that when a certain field (Volunteer_Status__c), a picklist value, is updated to the selection "Screening Completed" a new record is created under the Subject object that replicates the information stored under the volunteer record.

If someone could provide some instruction it would be much appreciated!

Hey all,

 

I'm working on an application for enrolling volunteers in clinical trials. Each trial has specific criteria, age, BMI, etc. that must be met by the volunteer to be part of the trial. What I'm trying to do is ensure that a volunteer object meets the specific criteria before being able to be added to the trial object. 

 

I have created a dropdown list referencing all trials on the volunteer record and have played around with filters for some of the criteria. However, certian criteria are based on formulas and I have not found a way to bring these values into the lookup filter. From what i've read it doesn't look likea  lookup filter can interact with a formula field.

 

Is there some way to create a "dummy" number field that will simply hold the same value as the field populated by my formula?

 

Any help would be much appreciated.

 

Hey All,

 

I'm following the steps laid out in the force.com developer workbook but have hit a snag. I've created the merchandise report as instructed but now the workbook is asking me to pull fields from the "Line Item" folder. This folder is not available in my fields view.

 

I've gone back and double checked the lookup relationship created in the earlier stages and everything appears correct. Am I missing something here? I would assume to have access to these fields I'd need to create something like a "Merchandise & Line Items" report but 1) that's not an option and 2) the workbook clearly says this is done through a merchandise report.

 

Any help would be much appreciated.

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
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
Hi all,

I'm looking for some guidance on how I would go about writing a trigger that creates a task for a number of records. What I want to do is that when a new record is created under my object Blood_Draw a task is assigned to all of the records of another object Subjecct. Both the Blood_Draw and Subject objects have a child relationship with another object I have called Trial. The Blood_Draw records are each related to a trial so I would only want the subject records that are also related to the same trial to be updated.

Any help would be much appreciated!


Hi all, I have a trigger that will create a new record in my object "subject" when a certain field on another object "volunteer" is updated. However, I would also like the subject to become a child record for the volunteer. Can someone provide some guidance as to how I can alter my current trigger?

Trigger copyVolunteertoSubject on Volunteer__c(after insert, after update)
{
     List<Subject__c> sub=new List<Subject__c>();
     for(Volunteer__c v : Trigger.new)
     {
           if(v.Volunteer_Status__c == 'Screening Complete')
           {
                   Subject__c s=new Subject__c();
                   s.First_Name__c=v.First_Name__c;
                   s.Age__c=v.Age__c;
                   s.BMI__c=v.BMI__c;
                   s.City__c=v.City__c;
                   s.Country__c=v.Country__c;
                   s.Date_of_Birth__c=v.Date_of_Birth__c;
                   s.Email_Address__c=v.Email_Address__c;
                   s.Gender__c=v.Gender__c;
                   s.Height__c=v.Height__c;
                   s.Last_Name__c=v.Last_Name__c;
                   s.Phone_Number__c=v.Phone_Number__c;
                   s.Postal_code__c=v.Postal_code__c;
                   s.Province__c=v.Province__c;
                   s.Street_Address__c=v.Street_Address__c;
                   s.Weight__c=v.Weight__c;
                   s.Trial__c=v.Trial__c;
                   //add other fields of subject here and add volunteer values in that.
                
                   sub.add(s);
            }
            if(sub.size()>0)
            insert sub;
     }
}
Hi all, I want to preface this by saying I have absolutley zero knowledge of coding and how to write an apex trigger. However, I do know the result i'm trying to achieve so I'm hoping my description will be enough for someone to provide some help.

My situation is the following: I have 2 custom objects Volunteer and Subject. What I want to happen is that when a certain field (Volunteer_Status__c), a picklist value, is updated to the selection "Screening Completed" a new record is created under the Subject object that replicates the information stored under the volunteer record.

If someone could provide some instruction it would be much appreciated!

Hey all,

 

I'm working on an application for enrolling volunteers in clinical trials. Each trial has specific criteria, age, BMI, etc. that must be met by the volunteer to be part of the trial. What I'm trying to do is ensure that a volunteer object meets the specific criteria before being able to be added to the trial object. 

 

I have created a dropdown list referencing all trials on the volunteer record and have played around with filters for some of the criteria. However, certian criteria are based on formulas and I have not found a way to bring these values into the lookup filter. From what i've read it doesn't look likea  lookup filter can interact with a formula field.

 

Is there some way to create a "dummy" number field that will simply hold the same value as the field populated by my formula?

 

Any help would be much appreciated.

 

Hey All,

 

I'm following the steps laid out in the force.com developer workbook but have hit a snag. I've created the merchandise report as instructed but now the workbook is asking me to pull fields from the "Line Item" folder. This folder is not available in my fields view.

 

I've gone back and double checked the lookup relationship created in the earlier stages and everything appears correct. Am I missing something here? I would assume to have access to these fields I'd need to create something like a "Merchandise & Line Items" report but 1) that's not an option and 2) the workbook clearly says this is done through a merchandise report.

 

Any help would be much appreciated.