cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JohnMacDougall
Advocate IV
Advocate IV

Trigger condition with SharePoint mutli-select choice column

Trigger is when a SP list item is created or modified.

 

I'm trying to create a trigger condition for a SP list choice column which can have multiple selected choices.

 

 

 

    "NotificationStatus": [
      {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 0,
        "Value": "New"
      },
      {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 1,
        "Value": "Pending"
      }
    ]

 

 

 

The output from the triggerbody might looks like above.

 

How can I create a "contains" condition?

 

 

 

@contains(join(triggerOutputs()?['body/NotificationStatus'],';'),'New')

 

 

 

I can do the above, but this isn't very elegant. as it turns the object into a text string then sees if it contains New as a substring.

 

I can foresee some issues with this. Like what if one of the choices is SharePoint, since that's always going to be in the string due to #Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference

 

 

 

["New","Pending"]

 

 

 

Is there a proper way to get the above array from the original object and use the contains function on this array instead?

 

Yes, I've got something that seems to work. But want to know the proper way.

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @JohnMacDougall,

 

I believe there is also an NotificationStatus#ID field in the trigger outputs. That field uses the ids of the choice options. You might be able to use that check for New and Pending at the same time.

 

Try this expression:

@equals(triggerOutputs()?['body/NotificationStatus#Id'], createArray(0,1))

 

Btw, in this example the New value always needs to be the first select value in the choice column. If you want to avoid that you probably need to add an OR to the expression for the 1,0 combination.

 

orderselectchoicevalues.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @JohnMacDougall,

 

I believe there is also an NotificationStatus#ID field in the trigger outputs. That field uses the ids of the choice options. You might be able to use that check for New and Pending at the same time.

 

Try this expression:

@equals(triggerOutputs()?['body/NotificationStatus#Id'], createArray(0,1))

 

Btw, in this example the New value always needs to be the first select value in the choice column. If you want to avoid that you probably need to add an OR to the expression for the 1,0 combination.

 

orderselectchoicevalues.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


JohnMacDougall
Advocate IV
Advocate IV

@Expiscornovus I saw that array, thanks for the tip.

 

@contains(triggerOutputs()?['body/NotificationStatus#Id'],0)

 

This will do the trick (in a more elegant way than my join solution). I just need to make sure the choice order in SP are not changed (a little uneasy about that). 

nixlyn
Regular Visitor

This helped me Anton, thanks. To add on...If you put the choices in a List and reference that, you don't have to worry about the ID changing. I put an example here.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,325)