+ Start a Discussion

How to erase value from text field while updating record ?

Hi All,

How to erase value from text field while updating record?

Reauirement :
i have one text field, while creating a record it is required field and while updating same record, i would be erase value from text field.?

please let me know how can i achive this .Give me example code also.

Thanks in advance.
Hi Chinnodu,

Write a validation rule on insert 


James Wilson 57James Wilson 57
When you find a matching record, that record becomes the current record, and you can then edit or delete it. Click the field that you want to search. On the Home tab, in the Find group, click Find, or press CTRL+F. Click the Find tab. In the Find What box, type the value that you want to match. Abyssinia Ethiopian Menu (https://centralmenus.com/abyssinia-ethiopian-menu-prices-locations/)
Ravi Dutt SharmaRavi Dutt Sharma
Hi China,

You can use below code for your requirement. On lead insert, it make the City mandatory and on lead update, it will blank out the value from City.
trigger LeadTrigger on Lead (before insert) {
    if(Trigger.IsBefore && Trigger.isInsert){
    if(Trigger.isBefore && Trigger.isUpdate){
public class LeadTriggerHandler {
    public static void checkForRequiredField(List<Lead> newLeads){
        for(Lead ld: newLeads){
                ld.addError('City cannot be blank');
    public static void emptyRequiredFieldValue(List<Lead> newLeads){
        for(Lead ld: newLeads){
                ld.City = '';