You need to sign in to do that
Don't have an account?
erikdozsa
Bypass required field on Visualforce page
Dear all,
I would like to ask for your suggestions regrarding the following situation:
I have to create a VF page to record expense line items. Since we don't want to add the rocords one by one the idea is to create some empty rows that the user can fill. We also need some required fields. I would like to have the fields required only if the user started to populate the row but for a completely empty row I would avoid the the error messages and would let the save complete:
And this is what happens after save:
How can I avoid this error popping up for a completely empty row? Any idea is more than welcome.
Thank you in advance!
Erik
I would like to ask for your suggestions regrarding the following situation:
I have to create a VF page to record expense line items. Since we don't want to add the rocords one by one the idea is to create some empty rows that the user can fill. We also need some required fields. I would like to have the fields required only if the user started to populate the row but for a completely empty row I would avoid the the error messages and would let the save complete:
And this is what happens after save:
How can I avoid this error popping up for a completely empty row? Any idea is more than welcome.
<apex:column id="col1"> <apex:facet name="header" >{!$ObjectType.Expenses_Line_Item__c.fields.SP_Expense_Category__c.label}</apex:facet> <apex:inputField value="{!item.SP_Expense_Category__c}" required="true" /> </apex:column> <apex:column id="col2"> <apex:facet name="header" >{!$ObjectType.Expenses_Line_Item__c.fields.SP_Expense_Date__c.label}</apex:facet> <apex:inputField value="{!item.SP_Expense_Date__c}" required="true"/> </apex:column> <apex:column id="col3"> <apex:facet name="header" >{!$ObjectType.Expenses_Line_Item__c.fields.Value__c.label}</apex:facet> <apex:inputField value="{!item.Value__c}" required="true" /> </apex:column>
Thank you in advance!
Erik
In addition to Scott's suggestion, the next best way would be to implement custom requiredness checking in an Apex controller or extension. In that case, for each row, you could check the three values, and if one or more fields are populated, but another one is not, then add an error to that field. (More info: https://www.salesforce.com/us/developer/docs/dbcom_apex290/Content/apex_System_SObject_field_addError.htm)
All Answers
IF(OR(expensedate1<>"",expenseitem1<>""),TRUE,FALSE)
In addition to Scott's suggestion, the next best way would be to implement custom requiredness checking in an Apex controller or extension. In that case, for each row, you could check the three values, and if one or more fields are populated, but another one is not, then add an error to that field. (More info: https://www.salesforce.com/us/developer/docs/dbcom_apex290/Content/apex_System_SObject_field_addError.htm)
Thank you guys. I went for the "addError" version.
In the meantime I have found another nice feature to mark fields like they are required: http://salesforce.stackexchange.com/questions/5462/required-field-mark-red-vertical-bar-not-coming
So I mark them and also validate the missing values during save.
Cheers,