A Visualforce page reads param id of a custom object CustomObjA__c and creates a new record of CustomObjB__c by mapping the required fields from A to B. It also maps the owner of record A to B. After inserting record B it redirects to that record page.
Here is a sample code of what is happening.
public PageReference convert() {
PageReference pref;
CustomObjA__c objA = [select field1__c, field2__c, field3__c, OwnerId from CustomObjA__c where Id = :paramId];
CustomObjB__c objB = new CustomObjB__c (
fieldX__c = objA.field1__c,
fieldY__c = objA.field2__c,
fieldZ__c = objA.field3__c,
OwnerId = objA.OwnerId
);
insert objB;
pref = new PageReference('/' + objB.Id);
pref.setRedirect(true);
return pref;
}
The problem is when the record page for object B is loaded the Owner field on the page is blank. However, if I query the OwnerId in the dev console for B it shows the correct one that was mapped from A. If this is the case, then why is the Owner missing from the record page?
Any help or suggestion would be much appreciated.
ObjB
? Please show the ObjB VF markup