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
Pablo ArgentinaPablo Argentina 

Formula comparation

Hi Guys.

Now i need something strange.

 

I have a picklist with some names and a autogenerated field with the name of the person who is creating the lead (Created By).

 

I want to make a comparison between this two fields. If the picklist value name is the same as created By, everything is ok, if not.... ERROR MESSAGE!

 

Any idea???

thanks in advance

Pablo

cloudsuccesscloudsuccess

Sounds like a Validation Rule, such as IF(Field_1__c <> Field_2__c) then the error message you want to display.

Pablo ArgentinaPablo Argentina

Yes CloudSucces, is something like that, the problem are two.

1.- field_1 is a pickList, so, i think that the sentence is different (ISPICKVAL or something like that)

2.- field_2 isn't a personalized field, it's a standard field. i didn't create it and don't know how to search and add it to the formula

 

Thanks again!!

Pablo

cloudsuccesscloudsuccess

Ah I understand - so this may be tricky because the "Created By" standard field is CreatedById (which obviously contains the Id of the user record rather than their full name) and if you have plain text values in the picklist they will not match. Have you considered doing something with an Apex trigger (this way you could get the users name through a SOQL query)?

 

There may be a better way of approaching this, but I think it may be difficult using a regular formula / validation as you can't get the users name from the CreatedById field (unless someone oh here knows how?)

BA_AdminBA_Admin

if you go to validation rule , you an search for the field created by username i guess it's CreatedBy.Username

Pablo ArgentinaPablo Argentina

WOW!!! You know what you are talking about... i... don't!!

 

Don't know how to use Apex trigger...

 

I'll tell you what i'm trying to do, maybe there's an easy way.

 

I have two different pick lists, the first one with 1000 salespoints the second one with the State (Location).

I don't want users to select location because they are really stupid and will select the wrong one.

So, i decided to create a validation rule, but the problem is that the first picklist shouldn't have more than 300 records, so... it's impossible.

So, i decided to create a new picklist field with the salesperson. My idea is to create a validation rule with the salesperson and the state. This is ok, but i'm not sure that salesperson will select their names (can happen), so i want to check the salesperson pickvalue with the created by field.

 

If you have any other idea... WELLCOME!!!

 

thanks

BA_AdminBA_Admin

Here you go

AND((ISPICKVAL( Test__c,'')) != (CreatedBy.Username = ''))

 

Here Test is my picklist with usernames

cloudsuccesscloudsuccess

BA_Admin has nailed it, user fields used to have restrictions on use in formulas but it looks like those have now gone (thankfully!)

goabhigogoabhigo

So, if SalesPerson (picklist) is equal to CreatedBy user, then error should be thrown, is it?

If yes then,

CONTAINS( CreatedBy.LastName , TEXT(SalesPerson__c))

 

I hope your SalesPerson picklist doesn't contain usernames (like pablo@company.com). If it contains then,

CreatedBy.UserName = TEXT(SalesPerson__c)

 

Hope it helps.