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);
    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.

  • You are using a VF page for ObjB? Please show the ObjB VF markup
    – cropredy
    Apr 29, 2016 at 0:57
  • No, after mapping and inserting obj B, the page redirects to the standard record page of obj B record and thats where the Owner field is empty. Apr 29, 2016 at 2:49
  • 1
    Permissions issue?
    – Adrian Larson
    Apr 29, 2016 at 4:37
  • But then shouldn't it not let me go through the insert? It should give an error on the vf page itself, right? Apr 29, 2016 at 13:22

1 Answer 1


So, this is going to sound very dumb but the client I am working for created a custom owner field for some unknown reason and replaced the standard field with it. So the owner was getting mapped properly to the standard owner field but the custom field was the one present on the record layout.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .