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
Anshuman ParhiAnshuman Parhi 

make the field as mandatory while the udation of the record

make the field as mandatory while the udation of the record .

Hello Expert,
any solution for this admin requirement
Best Answer chosen by Anshuman Parhi
CharuDuttCharuDutt
Hii Anshumann 
You Can Try Validation rule Or Trigger
Or
You Can Make The Field Required By Checking The Required CheckBox  While Creating Or Editing Fields.
Validation Rule

For Example 

1   AND(
   ISBLANK(AccountNumber),
   NOT(ISNUMBER(AccountNumber))
)

2  Address = null

3  ISPICKVAL( Type , "Industry")


Trigger


trigger AccountTrigger2 on Account (before update) {
      
    if (Trigger.IsBefore  && Trigger.IsUpdate) {
     for(account acc : trigger.new){
             If(Acc.Type == 'Industry'){
               Acc.Type.AddError('Can't Save Record);
               }
         }
    }
}


Please Mark It As Best Answer if It Helps
Thank You!

 

All Answers

SwethaSwetha (Salesforce Developers) 
Hi Anshuman,
To make a field mandatory,
1. Make the field “Required” at the time of field creation by checking the “Required” check box.
2. Make the field Required through Page Layout by checking the “Required ” checkbook in Field Properties.
3. Validation Rules can also be used to make the field mandatory. In Error Condition Formula, one can use ISBLANK(“FieldName”);.
4. Triggers can be used to make field mandatory. Ex. If a user try to insert the record without the field which is required, we can throw the page massage specifying to fill up required fields.(Using Trigger.addError()).
5. One can make field mandatory through Visualforce.(If the field is getting referenced) by setting the required attribute in       <apex:inoutField> to True.

Related: https://help.salesforce.com/articleView?id=000324555&mode=1&sfdcIFrameOrigin=null&type=1
https://www.forcetalks.com/salesforce-topic/how-many-ways-we-can-make-field-required-in-salesforce/

If this information helps, please mark the answer as best. Thank you
CharuDuttCharuDutt
Hii Anshumann 
You Can Try Validation rule Or Trigger
Or
You Can Make The Field Required By Checking The Required CheckBox  While Creating Or Editing Fields.
Validation Rule

For Example 

1   AND(
   ISBLANK(AccountNumber),
   NOT(ISNUMBER(AccountNumber))
)

2  Address = null

3  ISPICKVAL( Type , "Industry")


Trigger


trigger AccountTrigger2 on Account (before update) {
      
    if (Trigger.IsBefore  && Trigger.IsUpdate) {
     for(account acc : trigger.new){
             If(Acc.Type == 'Industry'){
               Acc.Type.AddError('Can't Save Record);
               }
         }
    }
}


Please Mark It As Best Answer if It Helps
Thank You!

 
This was selected as the best answer