cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bh4017
New Member

Use form submission to look up a list of users and then Teams message those users

I am building a simple ticket system which takes the response from a form and populates a "ticket" list.  This is all working quite nicely.

One of the responses on the form is 'category', and this really determines who should react to the submitted ticket.

I would like to automatically send a Teams message to the relevant people based on the 'category' choice that is made in the form.

One idea I had was to create another list which marries categories to employees.  So for example, something like this:

Joe Bloggs | Category A
Sue Storm | Category A
Jane Doe | Category B
...
Then if someone selects Category A on the form, then when it is submitted I would look in the above list and somehow collect the Joe Bloggs and Sue Storm entries and Teams them some details.

Would an experienced Power Automate user like to hazard a guess as to whether this would be possible? And if so maybe you would be kind enough to pass on some hints to send me off in the right direction.

Many thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User II
Super User II

Hi @bh4017,

 

One approach could be to create an array in your flow with the mappings of categories and email addresses and filter that array based on the response in the form.

 

Below is an example of that.

 

1. Add a compose action. Use a mapping like below.

 

 

 

[
  {
    "Category": "Category A",
    "Email": "joebloggs@contoso.onmicrosoft.com"
  },
  {
    "Category": "Category A",
    "Email": "suestorm@contoso.onmicrosoft.com"
  },
  {
    "Category": "Category B",
    "Email": "janedoe@contoso.onmicrosoft.com"
  }
]

 

 

 

categorymapping.png

 

2. Add a parse json action. Use the outputs of the previous compose as content. I used the following schema

 

 

 

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

 

 

 

 

parsejson_categorymapping.png 

 

3. Add a filter array action. Use the Outputs of the Parse Json for the From field. Compare the Question with the Category value. This should result in only rows with the correct category.

 

filterarray_categories.png

 

4. Within an apply to each you can send all the individual employees a message via Post a message as the flow bot to a user action by using the email field from the filter array action.

 

postamessageasaflowbot.png

 

 

View solution in original post

7 REPLIES 7
Expiscornovus
Super User II
Super User II

Hi @bh4017,

 

One approach could be to create an array in your flow with the mappings of categories and email addresses and filter that array based on the response in the form.

 

Below is an example of that.

 

1. Add a compose action. Use a mapping like below.

 

 

 

[
  {
    "Category": "Category A",
    "Email": "joebloggs@contoso.onmicrosoft.com"
  },
  {
    "Category": "Category A",
    "Email": "suestorm@contoso.onmicrosoft.com"
  },
  {
    "Category": "Category B",
    "Email": "janedoe@contoso.onmicrosoft.com"
  }
]

 

 

 

categorymapping.png

 

2. Add a parse json action. Use the outputs of the previous compose as content. I used the following schema

 

 

 

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

 

 

 

 

parsejson_categorymapping.png 

 

3. Add a filter array action. Use the Outputs of the Parse Json for the From field. Compare the Question with the Category value. This should result in only rows with the correct category.

 

filterarray_categories.png

 

4. Within an apply to each you can send all the individual employees a message via Post a message as the flow bot to a user action by using the email field from the filter array action.

 

postamessageasaflowbot.png

 

 

View solution in original post

Thank you very much indeed for your detailed response!

I tried it out and unfortunately it doesn't work for me.  The 'Apply to each' action does not execute when in my form submission I set a category which matches an associated entry in the JSON content entered in the 'Compose' step.

The logic looks good though and I feel like this will work if I can get the mapping of categories to an array to work.

 

I am completely new to Sharepoint and Flows so I think the first place to start is to try and get a handle on these Compose, Parse JSON and Filter Array steps so that I can hopefully figure out why it doesn't map an entered category on the form response.

Expiscornovus
Super User II
Super User II

Hi @bh4017,

 

Just to double check. Can you have a look at one of your flow runs and double check the output of the get response details action?

 

In my tests I saw some instances of Microsoft Forms putting an additional new line character at the end of my question response value.

{
  "responder": "dennis",
  "submitDate": "4/17/2021 12:49:02 PM",
  "rca5dfa207e8b4e6b9bdcca55134f5169": "Category A\n"
}

 

newlineinchoice.png

OK, interesting.  First of all I was not aware I could review previously executed flows and get their details, that is very helpful in and of itself.

Now, when I check the Get response details I don't see what you're getting.  I get a status code (200, which I guess means OK) and then I get some Headers details.  In the Headers I can see the Content-Type is application/json.
But, unfortunately, I don't see any JSON content at all.

Capture.PNG

Expiscornovus
Super User II
Super User II

Hi @bh4017,

 

I just noticed in your screenshot that you are using a different trigger action. You are using the SharePoint When a new item is created action. I also see you are trying to retrieve response number 12. Do you already have 12 responses in your form?

 

Btw, in my example I was using the When a new response is submitted trigger action:

https://docs.microsoft.com/en-us/connectors/microsoftforms/#when-a-new-response-is-submitted

Tut, you're absolutely right!

What happened here is that I have another flow which takes the form response and populates a list and that is working.  Then, with this flow, my idea was to trigger off the population of the list.  Then when you replied with your suggestion and I attempted to implement it I neglected the subtle different between a Form response and the Sharepoint item.

Now, it seems to me that if I am going to trigger off the form submission I might as well extend the flow I've already got working so that it sends my message as well as populates the list.

I'm having a play at the moment.  There is something a bit weird in the JSON output though.  Even though the Get response details step correctly outputs the field "Category" with its submitted value "Development", in the body the JSON content has some kind of unique ID in place of "Category".  Well, I'll have a play around with it and see what I can get working.  Thank you very much indeed for your kind help!

Capture.PNG

Even though it looks like there is some discrepancy in the JSON output from the form, it still works OK and I am able to map a Category in the form to a Category in my array.  Working fine and I've learned a lot.  I've also had a glimpse at how much there is still left to learn with this! Cheers!

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (69,033)