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.
Solved! Go to Solution.
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.
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.
@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).
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.
User | Count |
---|---|
89 | |
37 | |
26 | |
13 | |
12 |
User | Count |
---|---|
127 | |
54 | |
38 | |
26 | |
21 |