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
Giselle ArriojaGiselle Arrioja 

Insert or update in Validation Rule

Is there any way to know within a validation rule if the record is being evaluated is inserted (first time ) or updated ?

Example: I have this formula in a Validation Rule:

Total_Montos_Financiamiento__c -  PRIORVALUE(Monto__c) +  Monto__c >   Proyecto__r.Importe_Regla_Validacion__c

But when the record is being inserted for fist time, the system dont have PRIORVALUE, but the same amount I 'm trying to save and I want that the PRIORVALUE will be 0 (not the Amount) .

Any help? please!
Parker EdelmannParker Edelmann
Have you looked into the fuction ISNEW(), it might do the trick.
Mahesh DMahesh D
Hi Giselle,

In addition to Parker, providing more information for you.

ISNEW  ---  Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE.

Tips:
This function is available only in validation rules, field updates, workflow rules, assignment rules, and Process Builder formula criteria.
Use the NOT function to reverse the return values of TRUE and FALSE.
This function always returns FALSE when used in a workflow rule with a time-based trigger.
This function always returns FALSE when used in a field update for an approval action.

Please check the below link:

https://help.salesforce.com/apex/HTViewHelpDoc?id=customize_functions_i_z.htm&language=en_US#ISNEW

Please do let me know if helps you.

Regards,
Mahesh

 
DeepthiDeepthi (Salesforce Developers) 
Hello Giselle,

Try to check the below validation rule 
AND(ISNEW(),(Total_Montos_Financiamiento__c -  PRIORVALUE(Monto__c) +  Monto__c) >   Proyecto__r.Importe_Regla_Validacion__c)

Best Regards,
Deepthi
REVNAREVNA
IF(AND(ISCHANGED( LeadSource ),$Profile.Name <> "System Administrator"),true,false ) - something like this..
Parker EdelmannParker Edelmann
This may be what you're looking for:
Total_Montos_Financiamiento__c -  IF( ISNEW(), 0, PRIORVALUE(Monto__c)) +  Monto__c >   Proyecto__r.Importe_Regla_Validacion__c

If any one of us has answered your question, please let us know.
Thanks,
Parker