• Darb
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies

I am trying to deploy a change set from a sandbox and an existing trigger is preventing me from doing so.  The test does not have the required coverage.  The error I get is System.QueryException: List has no rows for assignment to SObject.  The test code is as follows:

@isTest
private class LeadTriggerTest {

    static testMethod void LeadTest() {
       String testleadid='';
       Lead testlead = new lead();
       testlead.status='new';
       testlead.lastname='Test';
       testlead.company='Test';
       testlead.description='test';
       testlead.country='United Kingdom';
       //get one user of proper type, use the where clause to filter
       user u=[select id,name from user where user.name='jonathan parker' LIMIT 1 ];
       system.runas(u){
         try{
            insert testlead;
            testlead.country='Norway';
            update testlead;
            testleadid=testlead.id;  //if created correctly
          }catch(DMLException e){
             system.assert(false, 'Error occurred inserting test record:'+e.getDMLMessage(0));
            }
          }
         Lead checkcase = [select id,name from lead where id=:testleadid];
         
         
    }
}

 

  • August 16, 2012
  • Like
  • 0

I want to create a new case from an opportunity.  I have built the connection between the two using a lookup relationship.  Now I have a button on the case related list to allow users to create a new case directly from the opportunity.  I want to make it as easy as possible by pulling in related information from the opportunity so the user does not have to reenter it. The challenge I now have is that I have multiple accounts with the same name and the user must then select the correct account.  Is there a way to pull the account from the opportunity without having the user look the correct one up from a list?  The button URL is listed below. 

 

 

 

/500/e?&cas4={!Opportunity.Account}&cas8=Medium&CF00N50000002Seac={!Opportunity.Name}&cas11="Opportunity"&RecordType=01250000000DvtV

  • May 14, 2012
  • Like
  • 0

I am trying to write a trigger that will update the owner of a record with a value in one of the records fields.  I have never written a trigger before and this is what I have come up with so far.

 

 

trigger changeorderowner on Oracle_Order__c (before insert) { //Change the order owner before saving to the data base //Select the new orders where the current owner is not equal to the Owner as noted in the ERP system List<Oracle_User_Name__c> changeorderowner = [SELECT Oracle_User_Name__c From Oracle_Order__C WHERE Oracle_User_Name__c != Owner FOR UPDATE]; for (Oracle_User_Name__c li: changeower) { if (Oracle_User_Name__c != owner) { owner = Oracle_User_Name__c;} update Oracle_User_Name__c; }

 Any help would be apprecaited  

 

  • March 08, 2010
  • Like
  • 0
I have a custom objects that receives records from an external system.  When the records come in I want to assign them to a specific user to maintain security.  I believe a trigger would work best but have no experience creating one.  Can anyone help?
  • March 02, 2010
  • Like
  • 0
I need to create a lookup to a custom field on the account object.  A standard lookup will only go the account and I need to reference a specfic field, not the account name.  Any ideas?
  • January 15, 2010
  • Like
  • 0

I want to create a new case from an opportunity.  I have built the connection between the two using a lookup relationship.  Now I have a button on the case related list to allow users to create a new case directly from the opportunity.  I want to make it as easy as possible by pulling in related information from the opportunity so the user does not have to reenter it. The challenge I now have is that I have multiple accounts with the same name and the user must then select the correct account.  Is there a way to pull the account from the opportunity without having the user look the correct one up from a list?  The button URL is listed below. 

 

 

 

/500/e?&cas4={!Opportunity.Account}&cas8=Medium&CF00N50000002Seac={!Opportunity.Name}&cas11="Opportunity"&RecordType=01250000000DvtV

  • May 14, 2012
  • Like
  • 0

I have created a custom "New" button for Case so that we can have it on the Opportunity page layout Case related list. If I specify the record type in the URL I can pass in values via URL parameters. But If I try to have the button call recordTypeSelect then I can't seem to get past the record type selection screen. I want to be able to fill in some fields but still allow user to select record type. Can this be done?

I am trying to write a trigger that will update the owner of a record with a value in one of the records fields.  I have never written a trigger before and this is what I have come up with so far.

 

 

trigger changeorderowner on Oracle_Order__c (before insert) { //Change the order owner before saving to the data base //Select the new orders where the current owner is not equal to the Owner as noted in the ERP system List<Oracle_User_Name__c> changeorderowner = [SELECT Oracle_User_Name__c From Oracle_Order__C WHERE Oracle_User_Name__c != Owner FOR UPDATE]; for (Oracle_User_Name__c li: changeower) { if (Oracle_User_Name__c != owner) { owner = Oracle_User_Name__c;} update Oracle_User_Name__c; }

 Any help would be apprecaited  

 

  • March 08, 2010
  • Like
  • 0