You need to sign in to do that
Don't have an account?
Creating custom fields for opportunity in test method?
I have one more test at the moment that I am trying to setup correctly. I think the issue is that the opportunity relies on a few custom fields and Im not quite sure exactly how I would create those in my test?
I can provide more info if nessesary.
Any insight would be much appreciated!
System.DmlException: Update failed. First exception on row 0 with id 006U0000007zk5DIAQ; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, aiMatch.aimatchOpportunityGrabTrigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.aiMatch.aimatchOpportunityGrabTrigger: line 22, column 1: []
private static testmethod void aimatchOpportunityGrabTest() { Profile p = [select id from profile where name='System Administrator']; User u = new User(alias = 'standt', email='sysadmin@testorg.com', emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id, timezonesidkey='America/Los_Angeles', username='aimatchtest@testorg.com'); System.runAs(u) { List<Opportunity> listOpportunity = new List<Opportunity>(); // Create Opportunity test data Opportunity o = new Opportunity (name = 'test', campaign_created_in_aimatch__c = true, ownerid = '005U0000000gvRnIAI', stagename = 'Renew', closedate = system.today(), aimatch_advertiser__c = 'a00U00000016hLW', campaign_start_date__c = Date.today(), campaign_end_date__c = Date.today() + 30); insert o; test.startTest(); listOpportunity.add(o); update listOpportunity; test.stopTest(); } }
Okay, figured out a better way.
Since I only need the one record theres no need to do a query. The I just get the ID value and the convert it to a string!
Thanks
All Answers
You are getting error because the user does not have permission on Event and Activity.
Please refer below article for more info :
http://kb.omni-ts.com/entry/68/
Try below code:
I have removed the Owner Id value in above code. give it a try.
Thanks JlTendra, but no luck with that!
I think one of my problems is that the method called relies on a custom object called aimatch_Advertiser__c. Its a lookup field which is required to save.
Im having trouble trying to create the test data for that field. I need the salesforce Id of my entry. This is what I am trying.
15:23:50.094 (94151000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject
I cant determine whether my query is wrong, or that I am not inserting the data correctly?
Thanks!
Jacob
Okay, so I figured it out.
But I have a question about how to get just the ID of my query. Below is what I am doing.
The string valueof I was getting was:
aiMatch__aiMatch_Advertiser__c:{Id=a00U0000005Ddt3IAC}
So I just did a substring to extract only the id value.
There must be a better way to do this?
Thanks!
Jacob
Okay, figured out a better way.
Since I only need the one record theres no need to do a query. The I just get the ID value and the convert it to a string!
Thanks