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
Rakesh Kumar 335Rakesh Kumar 335 

Need a workflow to populate other field's information on a specific field on lead object with a logic

"Time zone zip code" & "Property state"  are two fields on Lead object.
I need a workflow to populate "Time zone zip code" field with a value(defined by business) based on the "Property state" picklist value(Screenshot attached)
Example: If "Property state" has a picklist value = CA, then "Time zone zip code" filed should be equal to "94544"
NOTE THAT "Time zone zip code" CANNOT BE A FORMULA DUE TO SOME REASONS.
Business has defined 51 default values for 51 states, example: For NC, the valule should 28211. For TX, the value should be "73301"
How do i achieve this without using a formula field? can some one help please? i'm a beginner
workflow needed
Best Answer chosen by Rakesh Kumar 335
HARSHIL U PARIKHHARSHIL U PARIKH
I think you are going correct..Hit the save button and then you will see this screen,
User-added image


After that hit the SAVE button and then on IMMEDIATE ACTION, click Add Action.

User-added image

Inside the formula,
use this formula:
 
IF(ISPICKVAL([Account].Property_State__c , "CA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "NJ") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "MA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WV") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, null ))))))))

+++++++ up to all 50 states

Mine in on Account object but you can use your Lead object if that's what your object is then... Just LEAD inplace of ACCOUNT.
 

All Answers

Maharajan CMaharajan C
Hi Rakesh,

Use the process builder instead of workflow:

Because if you use WF then you have to create 51 WF. So simply go with the Process Builder here you can enter upto 200 nodes.

Thanks,
Raj
 
Rakesh Kumar 335Rakesh Kumar 335
Could you please provide step by step instructions. I'm a beginner. Thanks for your reply
HARSHIL U PARIKHHARSHIL U PARIKH
I would say you can do this by workflow OR with process builder OR with trigger.
Workflow would be possible but it would be so many of them so Process builder wins over workflow :)
In Trigger you will have to write a test cases so you decide;)

With the process builder.
1) Create a process on Account Object and select the condition on "Formula evaluates to true" and use the following formula,
!ISBLANK(TEXT([Account].Property_State__c ))
Action Type: Select Updtae Records and on Record Type: Select "Select the Account record that started your process"
Now make sure you have checkbox selected for "No criteria—just update the records!"

Now, select the field named Time Zone Zip Code and TYPE as FORMULA and thenbuild formula.
Your formula would look like below,
 
IF(ISPICKVAL([Account].Property_State__c , "CA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "NJ") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "MA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WV") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, null ))))))))

+++++++ up to all 50 states
Then activate the process but I wonder if you run out of charactor limitations.

With Apex Trigger:
2) Here we go,
JUST CHANGE IT TO YOUR SPECIFIC STATES AND ZIP-CODES. Right now its done for CA.
 
Trigger TimeZoneZipCodeUpdate on Account (Before Insert, Before Update, After UnDelete){
    
    If(Trigger.IsInsert || Trigger.IsUpdate || Trigger.IsUnDelete){
        For(Account act : Trigger.New){
            If(act.Property_State__c != null)
            {
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                 If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                 If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                 If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                 If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
                
                If(act.Property_State__c == 'CA')
                {
                    act.Time_Zone_Zip_Code__c = 94544;
                }
            }
        }
    }
}

All you need to do now is that make every if statement specific to your state and then add zip code accordingly.

Please mark it solved if it helps you resolve the issue!


 
Rakesh Kumar 335Rakesh Kumar 335
"Time zone zip code field" can only be a text Any alternative?
HARSHIL U PARIKHHARSHIL U PARIKH
I would say text is fine! Because if you use number let's say then the out put would look like 94,544 rather than 94544.
Rakesh Kumar 335Rakesh Kumar 335
Govind, i'm missing some thing...i'm dumb..need clear instructions...
pb
HARSHIL U PARIKHHARSHIL U PARIKH
I think you are going correct..Hit the save button and then you will see this screen,
User-added image


After that hit the SAVE button and then on IMMEDIATE ACTION, click Add Action.

User-added image

Inside the formula,
use this formula:
 
IF(ISPICKVAL([Account].Property_State__c , "CA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "NJ") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "MA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WA") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "WV") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, 
IF(ISPICKVAL([Account].Property_State__c , "XX") , 94544, null ))))))))

+++++++ up to all 50 states

Mine in on Account object but you can use your Lead object if that's what your object is then... Just LEAD inplace of ACCOUNT.
 
This was selected as the best answer
Rakesh Kumar 335Rakesh Kumar 335
Should there be some criteria for "False"?
HARSHIL U PARIKHHARSHIL U PARIKH
Nope!

Because your process would always fire since the criteria says whenever the field named Property_State__c is not blank means it contains any value then fire the process.

 
Rakesh Kumar 335Rakesh Kumar 335
I get this error
The formula expression is invalid: Formula result is data type (Number), incompatible with expected data type (Text).
HARSHIL U PARIKHHARSHIL U PARIKH
change IF(ISPICKVAL([Account].Property_State__c , "CA") , 94544, to some something like these..

IF(ISPICKVAL([Account].Property_State__c , "CA") , "94544",
Rakesh Kumar 335Rakesh Kumar 335
YOU ARE AWESOME!!!
IT'S EASY WHEN YOU KNOW HOW!
HEY CAN YOU BE MY TRAINER:)
I'M SERIOUS
HARSHIL U PARIKHHARSHIL U PARIKH
I am glad that I could help you Rakesh ! ... I can answer your questions here my friend!
Do me a favor... If it help you resolve the issue then please mark the question as solved, Best answered!
Rakesh Kumar 335Rakesh Kumar 335
Govind, this works fine, but the existing lead records with "Property state values" doesn't show zip code.
Example: A record has property state value as"CA", but the timezone zip code field is blank.
I guess this can be accomplished by updating the records. correct?
Any other way to have existing lead records show the values without records updation?
The problem is, last modified date and system dates get updated...when ii updat records
Maharajan CMaharajan C
Hi Rakesh,

Yes you have to update the existing leads with the help of Ids using Apex dataloader.

And also it will change the Lastmodified date,Last Modified by in the system but its not a problem.

And sorry i cant reply you at last night because i am already in too late night.

If you want any help then ping me via skype (maharaja0393).

Thanks,
Raj
HARSHIL U PARIKHHARSHIL U PARIKH
That is true! You will have to update them via data loader.
How?
1) Make a checkbox field named "Update__c" on Lead object.
2) Now Export all the Lead object Ids in one excel field and name the columns LEAD ID
3) Make another column in excel file and name it "Update Checkbox." put TRUE in this field for all the LEAD IDS.
4) make this file .csv
5) DownLoad the data loader and open it up. Once you open it, you will see series of windows which would direct you to where you want to go.
Just make sure you are matching LEAD ID to ID and Update Checkbox to Update__c. Once, mapped do the Mass update.

And within few munites you will see the process is fired for the all Lead records. Now, if you see everything is looking fine, then delete that Update__c from the lead object because you don't need it anymore.

Hope this helps!
Maharajan CMaharajan C
I think there is no need of extra fields just update the IDs but before that you have check the Validation Rule,WF email Alert,Trigger,any other Process Builder,Scheduled Actions because it will interfere our updating So we have to deactivate or bypass them.

Thanks,
Raj
Rakesh Kumar 335Rakesh Kumar 335
But the propbelm with update is, last modified gets update on all the records...