Skip to main content

We have a requirement-

If anyone create record from the UI/manually it should check the ISBLANK(Field_1__c)  if yes than it reflect the error.

AND

If the record is created by automation method than Field_1__c is not required.

AND

If anyone trying to update any existing record than it should check the ISBLANK(Field_1__c)  if yes than it reflect the error.

 

#Validation Rule #Validation 

2 个回答
  1. 2023年10月12日 09:56

    Hello @Abhishek Kumar Singh,

     

    Try This:

    AND(

    NOT(ISBLANK($User.UIThemeDisplayed)),

    OR(

    ISNEW(),

    ISCHANGED(Field_1__c)

    ),

    ISBLANK(Field_1__c)

    )

    This validation rule will display an error message if the Field_1__c field is blank and the record is being created or updated from the UI, but not if the record is being created by automation.

     

    The $User.UIThemeDisplayed a global variable to check if the record is being created or updated from the UI or by automation. This variable returns the name of the UI theme that the user is using, such as "Theme4d" for Lightning Experience, or "Theme3" for Salesforce Classic.

     

    https://help.salesforce.com/s/articleView?id=sf.dev_understanding_global_variables.htm&type=5

0/9000