You need to sign in to do that
Don't have an account?
salesforce@14
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Assigned To ID: owner cannot be blank: [OwnerId
Hi All,
I am trying to get owner id of parent object. but i am not able to get it.
I did like this .
[select id,ParentObject__r.OwnerId from Childobject__c];
can any one tell me how to resolve it..
Thanks in advance.
I am trying to get owner id of parent object. but i am not able to get it.
I did like this .
[select id,ParentObject__r.OwnerId from Childobject__c];
can any one tell me how to resolve it..
Thanks in advance.
I guess this method is in class, can you try using without sharing key word for your class.
All Answers
Can you plz post your code?
My code:
public static string pagesubmit(string recordId){
try{
Task newTask = new Task();
if(recordId!=null)
{
Child_Object__c child= [Select Id, Parent_Object__c,Parent_Object__r.OwnerId From Child_Object__c where Id=:recordId]; system.debug('@@@@@'+child);
newTask.WhatId =child.Parent_Object__c;
newTask.TargetMemberId__c = recordId;
newTask.OwnerId=Parent_Object__c.OwnerId;
insert newTask;
}
}
}
Thanks.
make sure your parent_Object__c is not a child of a master detail realtionship . becuase child object of master detail relationship doesnt have a ownerId. in that case you have to get the owner id of your parent object records master record
There is no master detail relationship for Parent_Object__c.
Thanks.
Pls change this:
newTask.OwnerId=Parent_Object__c.OwnerId;
to
newTask.OwnerId = child.Parent_Object__r.OwnerId ;
Le
Plz try below code. We will receive this kind of exception if we are trying to assign null value to the lookup or master field.
Thanks for your response.
First of all i am not querying the ownerid of parent object.It showing null and i dont know is there any other way.
Please help me.
Can you plz let us know your use case for this issue and also let me know after using above code what kind of exception you are receiving?
I am getting exception as
System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []
Thanks.
I guess this method is in class, can you try using without sharing key word for your class.
I solved my issue. Thank you very much.