function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
champ_vimalchamp_vimal 

Want to make InputField field with value OwnerId not required

Hi,

 

I am having a field called 'Key User' in VisualForce which takes value of OwnerId thus making it required field in VF page.

 

But sometimes, it may happen that Key User needs to be null. But when I try to do it, I get this error on save.

 

 System.DmlException: Update failed. First exception on row 0 with id a0GT0000000dImEMAU; first error: INVALID_CROSS_REFERENCE_KEY, Owner ID: owner cannot be blank: [OwnerId]

 

This is part of that VF page in which I am having the Key User field:- 

 

<apex:pageBlockSectionItem id="keyUserId">              
                <apex:outputLabel value="Key User" id="labelUser"/>
                <apex:inputField value="{!tr.OwnerId}" id="inputUserId" required="false"/>
              </apex:pageBlockSectionItem>

 

 

Please advise.

 

Thanks,

 

Vimal 

bob_buzzardbob_buzzard

You can't save a record back without an owner, which is why you are getting this error.

 

Can you tell us a bit more about what you are trying to achieve?  Do you have a field called Key User on your sobject that you want to initialise from the owner and then allow users to change?