• JaimieLives
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Hello,

A Newbie question I'm sure, but...

 

What is the proper method to define and insert a Queue via an Apex Trigger or Test Class?

I'm good with standard & custom sObjects and the like, but I've not been able to find any clear documentation for inserting queues.

 

I found the metadata reference, but I'm not sure it applies to Apex:

 

When I use a statement like this:

 

Queue myQueue = new queue(email=queEmail,name=queName,fullName=queFullName,queueSobject=Case);

  

I get this error:

 

Error: Compile Error: Entity 'Queue' not accessible in version 25.0 at line 2 column 8

 

this is line 2

 

public class caseUpdateShadowUser_Test

  

So, can someone tell me what I've missed, or simply provide or direct me to a clear explanation of how to define and insert a Queue via a Trigger or Test Class?

 

Thanks,

 

Jaimie

 

 

OK. I'm tired, but can someone tell me why I keep getting "Error: Compile Error: Variable does not exist: c at line 42 column 16", when "c: is defined just a few lines above? Here's the relevant code...

 

trigger createCaseFromProject on SFDC_Project__c (after insert) {
    
    // iterate over the list of Project records being processed in the trigger and
    // create the required cases
    for (SFDC_Project__c prj : Trigger.new)

        //Define the Cases to Insert, then insert them

        // 01230000001B8slAAC   Account & Billing
        Case c = new Case(
            RecordType = '01230000001B8slAAC',
            Project__c = prj.Id,
            Subject = prj.Account__r.Name & ': Subject ',
            Description = ' Description ',
            Origin = 'From Project',
            SuppliedEmail = prj.Customer_Contact__r.Email,
            Contact = prj.Customer_Contact__r.Id,
            Account = prj.Account__r.Id,
            Status = 'New'
        );
        insert c;

}

 

The error is apparently in the line "insert c;"

But the variable is defined at the line "Case c = ..."

 

Or have my tired eyes missed something silly?

 

Thanks,

 

JaimieLivest

OK. I'm tired, but can someone tell me why I keep getting "Error: Compile Error: Variable does not exist: c at line 42 column 16", when "c: is defined just a few lines above? Here's the relevant code...

 

trigger createCaseFromProject on SFDC_Project__c (after insert) {
    
    // iterate over the list of Project records being processed in the trigger and
    // create the required cases
    for (SFDC_Project__c prj : Trigger.new)

        //Define the Cases to Insert, then insert them

        // 01230000001B8slAAC   Account & Billing
        Case c = new Case(
            RecordType = '01230000001B8slAAC',
            Project__c = prj.Id,
            Subject = prj.Account__r.Name & ': Subject ',
            Description = ' Description ',
            Origin = 'From Project',
            SuppliedEmail = prj.Customer_Contact__r.Email,
            Contact = prj.Customer_Contact__r.Id,
            Account = prj.Account__r.Id,
            Status = 'New'
        );
        insert c;

}

 

The error is apparently in the line "insert c;"

But the variable is defined at the line "Case c = ..."

 

Or have my tired eyes missed something silly?

 

Thanks,

 

JaimieLivest