You need to sign in to do that
Don't have an account?
Ritesh__
first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]
i am writing a test for my controller for that i have to insert event in test database my test method is
static TestMethod void Test1_TestInsertWithValue() {Meeting_Master__c master=new Meeting_Master__c(); Event event =new Event(); Profile p=[SELECT Id From Profile WHERE Name='Standard User']; User u2 =new User(Alias = 'newUser' , Email ='newuser@testorg.com' , EmailEncodingKey = 'UTF-8' , LastName = 'Testing', LanguageLocaleKey='en_US',LocaleSidKey='America/Los_Angeles', UserName='newuser@testorg.com',ProfileId=p.Id); event.OwnerId =u2.Id; event.StartDateTime =datetime.newInstance(2008, 12, 1); event.EndDateTime = datetime.newInstance(2008,12,30); event.subject='call'; event.WhatId=master.Id; insert master; insert event; ........... }
when insert event occur i am facing error System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId]
how to rectify this error??
Hi there, you didn't insert the User. Add
insert u2;
at the end of the block where you are adding its properties.
Please post back and let me know if this was it!
-Kemi
All Answers
Hi there, you didn't insert the User. Add
insert u2;
at the end of the block where you are adding its properties.
Please post back and let me know if this was it!
-Kemi
I am trying to get owner id of parent object. but i am not able to get it.
I did like this .
ParentObject__r.OwnerId
can any one tell me how to resolve it..
thanks.