cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nikola_bgd
Advocate II
Advocate II

Sharepoint choice field mapping

Hi,

 

I'm trying to build a flow that runs based on a choice field in a sharepoint list;

 

I have a choice fields with 4 choices lets say:

-green

-red

-yellow

-black

 

I want to be able to send an email based on these fields, but the catch here I want to avoid using a switch, but a kind of a map telling the flow that

 

green = green@email

red = red@email

 

and than use the result further on.

 

Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @nikola_bgd,

 

Yes, that would be possible. 

 

I would compose an array and filter that. But there are probably other approaches as well. 

 

Below is an example of that approach.

 

1. Add a compose with the following content

[
  {
    "Color": "Green",
    "Email": "green@contoso.onmicrosoft.com"
  },
  {
    "Color": "Red",
    "Email": "red@contoso.onmicrosoft.com"
  },
  {
    "Color": "Yellow",
    "Email": "yellow@contoso.onmicrosoft.com"
  },
  {
    "Color": "Black",
    "Email": "black@contoso.onmicrosoft.com"
  }
]

compose_colors.png

 

2. Add a parse json action with the following schema

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "Color": {
                "type": "string"
            },
            "Email": {
                "type": "string"
            }
        },
        "required": [
            "Color",
            "Email"
        ]
    }
}

parsejson_colors.png

 

3. Add a filter array. Configure it to filter it based on the color from your SharePoint list

filterarray_colors.png

 

4. Use the email value from the filtered array to send an email to the correct address. In the example below I am using this expression

body('Filter_array')?[0]?['Email']

 

sendtocolors.png

 

View solution in original post

8 REPLIES 8
Expiscornovus
Super User
Super User

Hi @nikola_bgd,

 

Yes, that would be possible. 

 

I would compose an array and filter that. But there are probably other approaches as well. 

 

Below is an example of that approach.

 

1. Add a compose with the following content

[
  {
    "Color": "Green",
    "Email": "green@contoso.onmicrosoft.com"
  },
  {
    "Color": "Red",
    "Email": "red@contoso.onmicrosoft.com"
  },
  {
    "Color": "Yellow",
    "Email": "yellow@contoso.onmicrosoft.com"
  },
  {
    "Color": "Black",
    "Email": "black@contoso.onmicrosoft.com"
  }
]

compose_colors.png

 

2. Add a parse json action with the following schema

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "Color": {
                "type": "string"
            },
            "Email": {
                "type": "string"
            }
        },
        "required": [
            "Color",
            "Email"
        ]
    }
}

parsejson_colors.png

 

3. Add a filter array. Configure it to filter it based on the color from your SharePoint list

filterarray_colors.png

 

4. Use the email value from the filtered array to send an email to the correct address. In the example below I am using this expression

body('Filter_array')?[0]?['Email']

 

sendtocolors.png

 

View solution in original post

annajhaveri
Super User
Super User

@nikola_bgd  you can do as follows:

 

1. Use initialize variable, and name it as emailaddress of type string

2. Use Set Variable action with following expression, replace 'Status/Value' with your columnname/value.

if(equals(items('Apply_to_each_6')?['Status/Value'],'green'),'green@test.com', if(equals(items('Apply_to_each_6')?['Status/Value'],'red'),'red@test.com','othercolor@test.com'))

 3. Then you can use value of variable directly in send email action 

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
Paulie78
Super User
Super User

Yes, it is possible. You would need a compose step with a JSON array like this:

[
    {
		"colour": "green",
		"email": "green@somedomain.com"
	},
	{
		"colour": "red",
		"email": "red@somedomain.com"
	},
	{
		"colour": "yello",
		"email": "yello@somedomain.com"
	},
	{
		"colour": "black",
		"email": "black@somedomain.com"
	}
]

You can then filter this array based on your field value and collect the email address in the matching result. This would be the method I would use, but there are other ways also.

Paulie78
Super User
Super User

This is also quite a tidy method:

concat(
if(equals(outputs('colour'), 'green'), 'green@email.com', ''),
if(equals(outputs('colour'), 'red'), 'red@email.com', ''),
if(equals(outputs('colour'), 'yellow'), 'yellow@email.com', ''),
if(equals(outputs('colour'), 'black'), 'black@email.com', '')
)

you would need to replace outputs('colour') with your field value.

I get an error with this one:

 

Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'Apply_to_each_6' referenced by 'inputs' in action 'Set_variable' are not defined in the template

@nikola_bgd , it looks like you are using something in your expression that is not part of your flow, can you provide screenshot of the flow and expression that you are using, so that i can point out whats wrong.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi,

 

I think your suggestion has an apply to each which is not present in a simple expresion that I'm trying to build. I'm actually trying to avoid an apply to each, this was your expresion:

 

if(equals(items('Apply_to_each_6')?['Status/Value'],'green'),'green@test.com', if(equals(items('Apply_to_each_6')?['Status/Value'],'red'),'red@test.com','othercolor@test.com'))

@nikola_bgd  Apply to each is there to get value of the status column from the Item, how you are getting the data from SharePoint List? Are you using Get Items action or getting data from trigger? It would be helpful if you can share screenshot of your flow.

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Top Solution Authors
Users online (2,750)