Auto assign tax code to opportunity using the related accounts zip code - Answers - Salesforce Trailblazer Community
Ask Search:
Casey LoockCasey Loock 

Auto assign tax code to opportunity using the related accounts zip code

I've been working on a way to auto populate the tax code on an opportunity based on the zip code of the related account. Relationship wise, the tax code is a look up field on the account and the opportunity. Typically the user manually assigns the tax code to the account and the opportunity based on the tax code name. The tax code name has a zip code in it so the user know what code to assign based on what the zip code is on the accounts address. To eliminate wrong tax codes being assigned to accounts and opportunities, especially opportunities, I want to create a rule or process that does that all for them. I've not been able to create a rule or process to do this. The problem I'm running into is the Salesforce wants a tax code assigned before it will allow any rules to run. No matter if its a lead conversion, new opportunity, or a new account.

I created a process builder rule to look at zip shipping zip code of the account and if it matches a zip code on a tax code record, it should attach that tax code record to the account through the Tax Code look up field. The rule fails to do this and I get this error.

"The flow failed to access the value for myVariable_current.PBSI__Tax_Code_r.Zip_Code__c because it hasn't been assigned"

Any suggestions on how to get this working?
Best Answer chosen by Casey Loock
Amnon KruviAmnon Kruvi
Hi Casey,

It sounds like you're trying to match an account to a tax code using the zip code - a field that's common to both objects. You should be able to do this, but you'll need to use a flow to do so.

Your flow should have 2 input variables: AccountId and Zipcode. Both would be text, and both marked available for input. Using a Get Records step, your flow will retrieve any tax code record where the zipcode field matches the zipcode variable, and if one is found, update the account record with the ID of the tax code (using the AccountId variable to update the right account). Lastly, you will want to build a process on the Account object that runs the flow, passing over the account's ID and zipcode to the variables.