8
votes
Accepted
SOQL bug for null required-lookup fields?
This occurs because of an optimization during the "query planning" phase of a query. The query optimizer removes null values from filters on required fields. This optimization allows Salesforce to use ...
7
votes
Accepted
How to find required fields for an sObject?
Please note that fields can be made required via other means which are difficult or impossible to detect. Validation rules, triggers, and Process Builder can all introduce errors when a field is not ...
7
votes
Accepted
Placing asterisk to to Lightning:input fields in LWC
You can use label-hidden variant and put label yourself:
<template>
<label>Middle Name</label>
<abbr title="required" class="slds-required">**</abbr>
<...
7
votes
Accepted
In order to check if a field is required or not, is the result of isNillable method sufficient?
First Approach -
For the field to be required it has to meet 3 conditions:
is Creatable
is NOT Nillable
is NOT Default on create
So your if condition should be as following:
if(field....
6
votes
Accepted
Why is the LastName field required for the contact? What is the best approach to import contacts that only have the first name?
As for the LastName being mandatory, I can only say that it's by design. And seems there were ideas to get it optional, but Salesforce doesn't have any plan to do so. So it is very unlikely we can get ...
4
votes
Accepted
How does SObjectType.newSObject() works?
It will simply instantiate a new empty Account object.
Required fields only come into play when you perform the DML. You will have to set those.
This and the describe classes are useful when the ...
3
votes
How to find required fields for an sObject?
Even though I'm not providing any answers to the original question, I want to add more information to this post that could be useful for others.
Apparently, the nillable field in the SObject Describe ...
3
votes
Accepted
apex:inputText required="true" doesn't work as in the documentation
You seem to be missing <apex:messages/> in your vf page. By definition, it says:
All messages that were generated for all components on the current page. If an <apex:message> or <...
3
votes
How does SObjectType.newSObject() works?
From the documentation:
Constructs a new sObject of this type
Basically:
Account newAcc = (Account)Account.sObjectType.newSObject();
is same as:
Account newAcc = new Account();
It returns the ...
2
votes
Compare field value to list of values in Visualforce 'Required' parameter
Just use a Set whitelist and add a Boolean property.
static final Set<String> whitelist = new Set<String> { 'option 1', 'option 2', 'etc.' };
public Boolean isAccountRequired { get { ...
2
votes
Required fields do not allow cancel
To add to the knowledge above, there is also a known issue with HTML-5 and commandbuttons which use "immediate=true":
https://success.salesforce.com/issues_view?id=a1p300000008YvNAAU
Even with ...
2
votes
Accepted
LEX Equivalent of Immediate = TRUE?
A immediate="true" solution is not needed in Lightning, because validation must be done by the developer, not the framework. Yes, the error appears automatically for you, but it won't stop you from ...
2
votes
How to find required fields for an sObject?
For API version <= 44.0, there is no explicit isRequired method but there are a few methods that you can leverage to find required fields:
for (Schema.SObjectField fieldToken : Schema.SObjectType....
2
votes
Accepted
make a required field in VF page
When there’s a required field in a VF page and we submit the form, sever does a validation to make sure those have values populated. If there are no values form submission is rejected.
You may want ...
2
votes
Accepted
Figure out which fields are required from Setup
As far as I know of, there's no way from UI to get that information.
But you can retrieve this information if you use Metadata API. You can use the attribute required on the CustomField metadata for ...
2
votes
Difference of data extension "required" and "nullable" attribute in marketing cloud?
As per the documentation
Primary Key - Determines whether the system considers field to be the primary key of the table
If you select this checkbox, the system requires that the value in this field ...
2
votes
Making Custom Field Required
You can make the field required:
At the "database level", by setting it as requiring a value in the Field's definition.
At the "page layout level", by setting it as required by ...
2
votes
Accepted
Unable to set required attribute for lightning input
The attribute you are referencing should be of type "Boolean" for representing true/false values. In JavaScript, all non-empty strings are truthy, so if you use the String attribute type, it ...
2
votes
Viewing and Updating Related Record when creating a Task
You can create a screenflow and attach it as a QuickAction in your Account (Company) object.
The advantages of these are:
You can get the Account record and check the Account Type, based on different ...
1
vote
Accepted
Required fields in before-save flows
Unfortunately, there's nothing you can do here, except to make the field optional. If you look at the Triggers and Order of Execution page, you'll see that requiredness is checked in step 2, before ...
1
vote
Accepted
LWC setCustomValidity on lightning-input-field
As workaround what you can do is set up a validation rule for that field and throw it field level so as to throw a custom error message.
In the below example I am throwing error at Email field of ...
1
vote
Flow Builder OR logic on required fields in same screen?
Conditional Visibility
You could have a radio button group to control the visibility of the other input components (by setting up conditional visibility on them). The options for this radio group ...
1
vote
Workflow - Set Account Name
No It is not possible to remove account name field from mandatory that is standard salesforce field of standard object.
The work around would be enter some dummy value while creating account and your ...
1
vote
Accepted
Hot to make a dynamic lightning:inputfield required
The specification of lightning:inputField does not specify required as an attribute. The documentation tab mentions the following:
To persist requiredness on a field, select the Required checkbox ...
1
vote
Required field validation error message in VF Page using Javascript? (No Alert box or Popup's)
You can create span below the input box, initially it will not be visible, but whenever form is submitted, you can check for values and make it visible if there is no value for the input.
This is ...
1
vote
How to skip Required fields upon auto-creation of an object record?
First of all: if field is required ONLY on page layout it shouldnt be required for any other action than creating the record manually by the user.
Secondly: you can use Apex trigger for that.
Third ...
1
vote
Figure out which fields are required from Setup
Jayant's answer is the better approach for an organization-wide review, and I wanted to add another approach that is limited but quicker for single-object checks.
You can run Tooling API queries from ...
1
vote
Accepted
Community Self Registration: make First Name required
Yes it is Possible, you have to define 2 attributes in the lightning component, a Boolean and a String.
<aura:attribute name="showError" type="Boolean" default="false" access="private"/>
<...
1
vote
Accepted
How can I enforce one checkbox or another
You need validation rules, so go through the link since you'll be working with them alot.
IF the validation rule return false, then user will be able to save.
So one or both of statements should ...
1
vote
Accepted
Difference of data extension "required" and "nullable" attribute in marketing cloud?
These two are actually exactly the same option - and it appears (judging from their documentation) that both will display 'required' sometime in the future and nullable will no longer be used.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
required-field × 109visualforce × 23
apex × 13
validation × 13
validation-rule × 10
required × 9
custom-field × 8
picklist × 6
page-layout × 6
fields × 6
lightning-aura-components × 5
lightning-web-components × 4
javascript × 4
formula × 4
lightning × 3
api × 3
workflow × 3
aura × 3
sobject × 3
rerender × 3
lightninginput × 3
actionsupport × 3
fieldsets × 3
unit-test × 2
community × 2