• amyh
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 12
    Replies
Hi, I'm begging for help 1 more time.

I have a trigger that compiles fine (thanks Drew). I cannot deploy it to the server, because of an error I get
that points to my testmethod (even though, I can run my test class and deploy it to the server). Could you
give me any insight to creating these test classes? Thank you.

trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c(after insert, after update)
{
    List<Id> myIDs = new List<Id>{}; //use this to store all the Product2 Ids to query for
       
    for (SFDC_520_QuoteLine__c obj : Trigger.new)
        {
            myIDs.add(obj.Product2__c) ;
        }
    //Need to move the SOQL Query out of the FOR LOOP otherwise you'll hit a governor limit in some scenarios
    Map<Id,Product2> productMap = new Map<Id,Product2>([select name  from Product2 where ProductCode IN :myIDs]);
   
    //Now loop through records again
    for (SFDC_520_QuoteLine__c obj : Trigger.new)
    { 
         if (obj.Shipping_Confirms_Order__c == True)
             {
                   Case newCase = new Case(
                     //Use the Map to get the Product2 Name out of the Map generated by the SOQL query above
                     Description = productMap.get(obj.Product2__c).Name + ' ' + obj.Description__c,
                     Subject = 'New Data Production Project',
                     Status = 'Not Started',
                     Product__c = 'Custom Data',
                     Priority = 'Sev-4 (when resources allow)',
                     Origin = 'Web'
                     );
                     insert newCase;
             }
     }
 }         


@isTest
public class TestClass {
  static testMethod void myTest() {
      SFDC_520_Quote__c q = [select id from SFDC_520_Quote__c where name='08-30287'];
    SFDC_520_QuoteLine__c LI = new SFDC_520_QuoteLine__c(Quote__c = q.ID,Shipping_Confirms_Order__c= true);
    insert LI; //this line is where the error is when I try to deploy the trigger
 }
}
  • December 09, 2008
  • Like
  • 0
Hello,

I'm very close to having my trigger fully functional, but I need to do a simple table
lookup for the record I am inserting. Could you please help me with the syntax.

Working Hardcoded:

ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [(select name ) from Product2 where ProductCode = 'My Product Code']; //:myid


Non Working with Variable


ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [(select name ) from Product2 where ProductCode = :myID];

I don't really get an error message except that my Test now fails when it attempts the insert.

Thank You/

Full Code:

trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c
(after insert, after update)


    ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [select name  from Product2 where ProductCode = :myID]; //:myid
       
        if (obj.Shipping_Confirms_Order__c == True) {
              Case newCase = new Case(
             
                Subject = 'New Data Production Project',
                Description = p.name + ' ' + obj.Description__c,
                Status = 'Not Started',
                Product__c = 'Custom Data',
                Priority = 'Sev-4 (when resources allow)',
                Origin = 'Web'
                );
                insert newCase;
        }
    }          
}
  • December 08, 2008
  • Like
  • 0
Hello,

I'm  trying to create my first trigger, but I get the error message:
Save error: Comparison arguments must be compatible types: Schema.SObjectField, Boolean   

What I'm trying to accomplish is to automatically generate a case when a user checks a box
on the Sales Order Line Item page.

Below is my attempt, and the error is on line 5.

I would greatly appreciate any help or direction.

thanks!!



trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c
(after update)

{       
    if (SFDC_520_QuoteLine__c.Shipping_Confirms_Order__c == True)
    {
              Case newCase = new Case(
                Subject = 'New Data Production Project',
                Status = 'Not Started',
                Product__c = 'XXX One (2.0)',
                Priority = 'Sev-4 (when resources allow)',
                Origin = 'Web' 
                );
                insert newCase;
    }
    else
    {
    }           
}
  • December 05, 2008
  • Like
  • 0
We have a system admin who installed something from the app exchange and created some custom pieces attached to that app.  That user will no longer be an admin, so I need to transfer the stuff he created to my login so that I can still access/edit it.  So far I have not figured out how to do this.  Anyone have any experience with this?
 
Thanks.
  • May 30, 2008
  • Like
  • 0
Hi, I'm begging for help 1 more time.

I have a trigger that compiles fine (thanks Drew). I cannot deploy it to the server, because of an error I get
that points to my testmethod (even though, I can run my test class and deploy it to the server). Could you
give me any insight to creating these test classes? Thank you.

trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c(after insert, after update)
{
    List<Id> myIDs = new List<Id>{}; //use this to store all the Product2 Ids to query for
       
    for (SFDC_520_QuoteLine__c obj : Trigger.new)
        {
            myIDs.add(obj.Product2__c) ;
        }
    //Need to move the SOQL Query out of the FOR LOOP otherwise you'll hit a governor limit in some scenarios
    Map<Id,Product2> productMap = new Map<Id,Product2>([select name  from Product2 where ProductCode IN :myIDs]);
   
    //Now loop through records again
    for (SFDC_520_QuoteLine__c obj : Trigger.new)
    { 
         if (obj.Shipping_Confirms_Order__c == True)
             {
                   Case newCase = new Case(
                     //Use the Map to get the Product2 Name out of the Map generated by the SOQL query above
                     Description = productMap.get(obj.Product2__c).Name + ' ' + obj.Description__c,
                     Subject = 'New Data Production Project',
                     Status = 'Not Started',
                     Product__c = 'Custom Data',
                     Priority = 'Sev-4 (when resources allow)',
                     Origin = 'Web'
                     );
                     insert newCase;
             }
     }
 }         


@isTest
public class TestClass {
  static testMethod void myTest() {
      SFDC_520_Quote__c q = [select id from SFDC_520_Quote__c where name='08-30287'];
    SFDC_520_QuoteLine__c LI = new SFDC_520_QuoteLine__c(Quote__c = q.ID,Shipping_Confirms_Order__c= true);
    insert LI; //this line is where the error is when I try to deploy the trigger
 }
}
  • December 09, 2008
  • Like
  • 0
Hello,

I'm very close to having my trigger fully functional, but I need to do a simple table
lookup for the record I am inserting. Could you please help me with the syntax.

Working Hardcoded:

ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [(select name ) from Product2 where ProductCode = 'My Product Code']; //:myid


Non Working with Variable


ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [(select name ) from Product2 where ProductCode = :myID];

I don't really get an error message except that my Test now fails when it attempts the insert.

Thank You/

Full Code:

trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c
(after insert, after update)


    ID myID = null;
        
    for (SFDC_520_QuoteLine__c obj : Trigger.new) {
        myID = obj.Product2__c ;
        Product2 p = [select name  from Product2 where ProductCode = :myID]; //:myid
       
        if (obj.Shipping_Confirms_Order__c == True) {
              Case newCase = new Case(
             
                Subject = 'New Data Production Project',
                Description = p.name + ' ' + obj.Description__c,
                Status = 'Not Started',
                Product__c = 'Custom Data',
                Priority = 'Sev-4 (when resources allow)',
                Origin = 'Web'
                );
                insert newCase;
        }
    }          
}
  • December 08, 2008
  • Like
  • 0
Hello,

I'm  trying to create my first trigger, but I get the error message:
Save error: Comparison arguments must be compatible types: Schema.SObjectField, Boolean   

What I'm trying to accomplish is to automatically generate a case when a user checks a box
on the Sales Order Line Item page.

Below is my attempt, and the error is on line 5.

I would greatly appreciate any help or direction.

thanks!!



trigger CreateCaseAfterShippingConfirmsOrder on SFDC_520_QuoteLine__c
(after update)

{       
    if (SFDC_520_QuoteLine__c.Shipping_Confirms_Order__c == True)
    {
              Case newCase = new Case(
                Subject = 'New Data Production Project',
                Status = 'Not Started',
                Product__c = 'XXX One (2.0)',
                Priority = 'Sev-4 (when resources allow)',
                Origin = 'Web' 
                );
                insert newCase;
    }
    else
    {
    }           
}
  • December 05, 2008
  • Like
  • 0
Hello

I am a newbie to salesforce coding and these forums so apologies if this is posted in the wrong place! I hope someone can help me out.

I recently implemented salesforce primarily to improve our case management process. A key requirement is to be able to monitor the time we have spent internally on a case vs the number of hours the customer has on their SLA and the corresponding time left i.e. SLA hours MINUS time spent so far. I downloaded a neat stop clock application from appXchange to provide a simple stop clock and it workw well. I have also figured out how to create the fields and everything is working to a point but....

Rather than have to go into each record and press save to trigger a field refresh, how can I update multiple records in one go?

Is there a simple bit of code that can run against a set of records and update a particular field? Do I need an S control - not really sure how to make one but someone suggested it would be a place to start?

 I have struggled to find an answer to something I have found simple in other systems (in Lotus I used agents set to run on schedule for example).

Any help or guidance would be much appreciated. Thanks in advance!