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
ChinnoduChinnodu 

How to avoid required field while updating record in the page using trigger ?

Hi All ,


Here my requirement is while creting a record i need required field and updaing the same record i don't want required field.

Example:
I) I Have one custom object Employee__c and field is DOB.Now  while creating a record i need required field , if value is not there , then it showing required value is missing
 2) I want update on same record then i have remove value from DOB field at that time i don't want required value.

Please suggest me, how can achive with example code.


Thanks in Advance.
Chinna
Best Answer chosen by Chinnodu
Ravi Dutt SharmaRavi Dutt Sharma
IF( ISNEW() , ISBLANK( AccountNumber ) , false)

This is a validation rule on account which checks enforces value in AccountNumber field on creation of account.

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
You can write a validation rule to check the value of DOB. The validation rule will check whether the record is newly created or an updated record by making use if ISNEW() function.
Ravi Dutt SharmaRavi Dutt Sharma
IF( ISNEW() , ISBLANK( AccountNumber ) , false)

This is a validation rule on account which checks enforces value in AccountNumber field on creation of account.
This was selected as the best answer
ChinnoduChinnodu
Thanks ravi Dutt Sharma: it 's working perfetly 
venu parasavenu parasa
IF( ISNEW() , ISBLANK( DOB__c ) , false)
While creation, if value is missing it throws error and while updating, it will not throw any error even though it is blank.