1

I am using the Address Lightning component in a screen flow. I have State and Country picklist enabled, so when the user selects a country, the state is enabled or not.

enter image description here

The problem is that the 'Country' value, and 'State' values, are saved as the value/name/label, and not the API 2 char code.

I don't see any additional settings on the Address component.

enter image description here

And when I create the lead, the Country code is empty, while the country has the value from the Picklist.

I am trying multiple scenarios:

But getting same issue: The country code in the object only gets the Name from the Address, and not the Value enter image description here

Any ideas?

2
  • Can you clarify the issue? I was able to use the address component and take the selected Country/state and have the Lead created correctly (CountryCode & StateCode auto-populate after insert based on value set in Country & State). Are you trying to use the values later on in your Flow - have you re-queried the created Lead record after you've created it? Commented Apr 14, 2022 at 12:17
  • Thank you, I am using the values from the address component to query other metadata, which is stored as iso_char values. This is done in a before flow on the lead. I don't want to create the lead, and than reevaluate.
    – Saariko
    Commented Apr 14, 2022 at 19:13

3 Answers 3

2
+200

The Address component only provides you with values as you noted and as is documented.

If you were to insert the record, then CountryCode & StateCode would be populated based on the value you passed to the record.

Since you indicated you can't do that (insert & then re-query), you'll have to do handle the mapping yourself based on the value you're given. You have a couple options

  1. Use Invocable apex to get the code based on the value
String countryCode;
String stateCode;

//get CountryCode
Schema.DescribeFieldResult fieldResult = User.Countrycode.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
System.debug('Picklist::'+ple);
for( Schema.PicklistEntry f : ple){
    if(f.getLabel() == yourCountryValue){
        //store value of code
        countryCode = f.getValue();
    }
}

//get StateCode
Schema.DescribeFieldResult fieldResult = User.statecode.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
System.debug('Picklist::'+ple);
for( Schema.PicklistEntry f : ple){
    if(f.getLabel() == yourStateValue){
        stateCode = f.getValue();
    }
}

//return values back to Flow to use in query
  1. Load in a Custom Setting or Custom Metadata Type a mapping of Country/State Values you can query in the Flow directly to get the corresponding code based on value.
1

I am the Product Manager for our screen flow components. Proper support for State and Country Picklists is coming soon, check out this idea for more updates: https://ideas.salesforce.com/s/idea/a0B8W00000GdgLIUAZ/flow-screen-components-include-validation-options-and-required-attributes

We're also adding a number of other fun features like Disabled, Required, and Google Address Lookup!

0

Is there a channel where we can report or upvote the need to fix this Screenflow issue w/ Salesforce?

Another work-around option if you need to stay in Flows:

  • Create a temporary contact record with the Mailing Country set.
  • Save then retrieve the record and assign the Mailing Country Code to a variable
  • Rollback database changes
  • Assign the variable's value to the destination Country Code field

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .