cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AMH08
Advocate I
Advocate I

Expression Building Issues

I am trying to build a flow triggers when a SharePoint list item is created. This flow sends an approval and emails people back for the created SharePoint list item.  I have the entire flow working, however there is a request I am having issues with. 

 

There are two fields of relevance in this SharePoint list. One is a multiple selection choice field, which will be referred to as [Social Type Field]. The second is basically an [Office Field] which specifies which branch of office the request is for. 

 

What is being requested is that for each of the items checked in the multiple selection choice field, a set of links is generated into an email to back to the requester. The links given depend on which of the checked items were selected. Further more, if a certain item is checked, it needs to give a specific link based on what was inserted into the office field. After some thought, I thought I could just build an expression that concatenated a bunch of if statements that returned blank if there wasn't a match and returned the link if either the necessary item was checked or if that specific value was checked and which office was specied. Although, this returns blank for some reason whenever I test the flow. I was wondering if I am even building this expression correctly or if someone has another idea how I can go about this. Below is a sample of the expression:

 

concat(


if(contains([Social Type Field],'Facebook All'), 'SITE: WEBSITE/<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Washington')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Vermont')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'New York')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Georgia')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Florida')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Iowa')), 'SITE: WEBSITE<p>', ''),
if(and(contains([Social Type Field],'Facebook Office'),equals([Office Field],'Ohio')), 'SITE: WEBSITE<p>', ''),
if(contains([Social Type Field],'Twitter'), 'SITE: WEBSITE<p>', ''),
if(contains([Social Type Field],'YouTube'), 'SITE: WEBSITE<p>', ''),
if(contains([Social Type Field],'Instagram'), 'SITE: WEBSITE<p>', '')

)

 

Upon further testing, I am seeing that everything is just returning FALSE. I can't get the Contain to find the value even if it's within the array. I know it's seeing the values because I posted the raw value into the email and get:

 

[{"Id":0,"Value":"Facebook All"}]

 

Even though the Contains was searching for "Facebook All" though, it returns False. If I use a Length espression it is successfully able to count these. So I don't understand why Contains is returning false when Length and the raw text appear correct. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @AMH08,

 

Could you please share a screenshot of your flow's configuration?

Could you please share a bit more about the [Office Field] in your SharePoint list?

 

I think there is something wrong with formula that you provided, the output of [Social Type Field] dynamic content returned is an object array, you could not use the contains function to check if a string is existed in this array (You could only check if an object is existed in this array).

 

I have created a SharePoint list on my side and the data structure of it as below:20.JPG

Note: The Social Type Field column is Choice type column with multiple selections, the Office Field column is a Single line of text type column.

 

 

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created" trigger, specify Site Address and List Name.
  • Add a Variables-> "Initialize variable" action, Name set to SocialTypeArray, Type set to Array and Value set to empty.
  • Add a "Apply to each" action, input parameter set to Social Type Field dynamic content.
  • Within "Apply to each" action, add a "Append to to array variable" action, Name set to SocialTypeArray, Value set to following formula:

 

item()?['Value']

 

  • Under "Apply to each" action, add a Compose action, Inputs set to following formula:
concat(
if(contains(variables('SocialTypeArray'),'Facebook All'), 'SITE: WEBSITE/<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Washington')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Vermont')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'New York')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Georgia')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Florida')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Iowa')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Ohio')), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'Twitter'), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'YouTube'), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'Instagram'), 'SITE: WEBSITE<p>', '')
)

Image reference:18.JPG

The flow works successfully as below:19.JPG

 

 

More details about using expression within flow actions, please check the following article:

Use expression in flow actions

 

 

Best regards,

Kris

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @AMH08,

 

Could you please share a screenshot of your flow's configuration?

Could you please share a bit more about the [Office Field] in your SharePoint list?

 

I think there is something wrong with formula that you provided, the output of [Social Type Field] dynamic content returned is an object array, you could not use the contains function to check if a string is existed in this array (You could only check if an object is existed in this array).

 

I have created a SharePoint list on my side and the data structure of it as below:20.JPG

Note: The Social Type Field column is Choice type column with multiple selections, the Office Field column is a Single line of text type column.

 

 

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created" trigger, specify Site Address and List Name.
  • Add a Variables-> "Initialize variable" action, Name set to SocialTypeArray, Type set to Array and Value set to empty.
  • Add a "Apply to each" action, input parameter set to Social Type Field dynamic content.
  • Within "Apply to each" action, add a "Append to to array variable" action, Name set to SocialTypeArray, Value set to following formula:

 

item()?['Value']

 

  • Under "Apply to each" action, add a Compose action, Inputs set to following formula:
concat(
if(contains(variables('SocialTypeArray'),'Facebook All'), 'SITE: WEBSITE/<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Washington')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Vermont')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'New York')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Georgia')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Florida')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Iowa')), 'SITE: WEBSITE<p>', ''),
if(and(contains(variables('SocialTypeArray'),'Facebook Office'),equals(triggerBody()?['Office_x0020_Field'],'Ohio')), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'Twitter'), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'YouTube'), 'SITE: WEBSITE<p>', ''),
if(contains(variables('SocialTypeArray'),'Instagram'), 'SITE: WEBSITE<p>', '')
)

Image reference:18.JPG

The flow works successfully as below:19.JPG

 

 

More details about using expression within flow actions, please check the following article:

Use expression in flow actions

 

 

Best regards,

Kris

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

With your documentation, I was able to figure out what I needed to get done in order to make this large expression work. I highly appreciate the assistance. 

 

For Future Reference:

 

 

To give more information on the Office field. I forgot to mention it is a single selection drop down which I basically referenced using: 

 

triggerBody()?['Office']?['Value']

 

I am not seeing how you add an image in body to this post but I will say it's an edit of the basic request approval template Flow.

 

It spills down into:

 

When a new item is created (In SharePoint List)


Initalize variable (Declare Array Variable)

Convert time zone (Format SharePoint Field Time)

Start an approval (Send Approval to specified people)

 

If yes

 

Apply to each (Build Social Type Array)

Inform item creator of approval (Email letting user know about the approval, including links to where things are/will be posted)

Update item (Update SharePoint list item with approval comments)

 

 

If no

 

Inform item creator of rejection (Let user know via email that the post was rejected and for what reasons, prompt to edit record)

Update item (updates SharePoint item of approval comments)

Do until (Delay Flow until the Item has been modified)

Send email with options (Send email to the approver to state item has been modified, offer button to change the approval status)

Do until (Delay Flow until email button has been pressed)

Update item (Updates approval status in SharePoint list item)

Apply to each (Build Social Post Array off the last item update)

Send an email (Email letting user know about the approval, including links to where things are/will be posted)

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (30,657)