-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
8Replies
test code error - list has no rows for assignment to SObject
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]; } }
-
- Darb
- August 16, 2012
- Like
- 0
- Continue reading or reply
Create a new Case from an opportunity - using a button
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
-
- Darb
- May 14, 2012
- Like
- 0
- Continue reading or reply
Trigger - update record owner with new field falue
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
-
- Darb
- March 08, 2010
- Like
- 0
- Continue reading or reply
Trigger to change the user
-
- Darb
- March 02, 2010
- Like
- 0
- Continue reading or reply
Creating a custom lookup for a field on the accout object.
-
- Darb
- January 15, 2010
- Like
- 0
- Continue reading or reply
Create a new Case from an opportunity - using a button
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
- Darb
- May 14, 2012
- Like
- 0
- Continue reading or reply
Custom new Case button - Pass in values and still allow record type
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?
- JesseA
- May 14, 2012
- Like
- 0
- Continue reading or reply
Trigger - update record owner with new field falue
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
- Darb
- March 08, 2010
- Like
- 0
- Continue reading or reply