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
sreenivasAppssreenivasApps 

validation rule on (WhatId) send an email task

Hi Guys,
I have a requirement, When we select otherthan a Case on RelatedTo field it should throw error on the same page i.e Send an Email Task page.

The rule is not firing at all. for trial and error i just tried by modifying the rule like " WhatId != Null ". So when we select any id in RelatedTo field it should throw error but its not throwing.

But when i am trying to create a "Log a Call" task , then its firing the validation. Why it is happening ?

So i write a trigger on Task,
event 'before insert' and trigger fires the validation on the next page not on the same page like
"
Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Please select a case...". 
Click here to return to the previous page.
"

How can i achieve this ?
 
kaustav goswamikaustav goswami
Can you please share the validation rule that you have written on Task object.

We can take a look at the validation first and then look at the trigger option.

Thanks,
Kaustav
sreenivasAppssreenivasApps
NOT(ISBLANK(WhatId))
 
kaustav goswamikaustav goswami
What I understand is that you are trying to have a validation on Taks that checks whether the relted to object is a case record. If not then the users should not be allowed to create a task.

You can try this validation rule

AND (
NOT( ISBLANK( WhatId ) ),
BEGINS(WhatId, '500') 
)

This should stop any user who tries to create a task that is not related to a case.

Sorry for the delay in replying.

Thanks,
Kaustav