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 II
Super User II

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

View solution in original post

3 REPLIES 3
Expiscornovus
Super User II
Super User II

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

View solution in original post

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
New Member

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (825)