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
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif 

validation rule on leads


I would like to have a validation rule where a lead owner will need to write their reason in the 'Notes' section (located at the right side of the page) when they unqualify a lead. need a step by step guide for this, including the code.
Best Answer chosen by Syaiful Anuar Abdul Latif
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif
i wqas given another code by the support team and it works. this is the code given to me:

AND(
ISCHANGED(Status ),
ISPICKVAL( Status ,"Unqualified"),
ISBLANK( SFDC_Reasons__c )
)

All Answers

RituSharmaRituSharma
Validation rule will not work in this case. Even if you write trigger, you can look into the Notes but can't validate if a particular note is added for capturing the specific reason. May be you can create a button with label Unqualify Lead, on the click of this button, open a flow where user can enter the comments. Store the comments in Notes object and change the lead status.
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif
right now, i have created a custom field call 'Reasons'. so right now, i would like to implement a validation rule where, when a lead owner unqualify a lead, the owner can only mark it as unqualify when they write the reason in the 'Reason' section (custom field that i created). if the 'Reason' section is empty, owner will not be able to unqualify the lead.
RituSharmaRituSharma
You may create a validation rule. Formula will be something like below:

And(ISPICKVAL(Status,"Closed - Not Converted"),PRIORVALUE(Status)!="Closed - Not Converted", 
Reasons__c=='',$User.Id==OwnerId)
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif
Thank you Ritu. Allow me to try and i will let you know if it works and if that is how i want the outcome to be like.
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif
i wqas given another code by the support team and it works. this is the code given to me:

AND(
ISCHANGED(Status ),
ISPICKVAL( Status ,"Unqualified"),
ISBLANK( SFDC_Reasons__c )
)
This was selected as the best answer
RituSharmaRituSharma
The code given by support team is not complete since it does not check for the user id.
Syaiful Anuar Abdul LatifSyaiful Anuar Abdul Latif
i see. Do you mind provide an explanation to me Ritu, on how it will effect me in the future?
RituSharmaRituSharma
As per the requirement(shared by you), validation should fire when lead owner is marking the lead as unqualified. So to check if you need to check if owner id is same as logged in user id.