cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StevenWade
Advocate III
Advocate III

How to: make certain Outputs non-required on Sharepoint 'For a selected item' trigger

Wanted to share an issue I recently ran into, and a quick fix. 

 

By default, all of the outputs you add to a SharePoint 'For a selected item' trigger are required, and there's no method to change the outputs to non-required via the UI. However, if you need a non-required output and you're willing to get into the json, you can change an output to non-required with the following steps:

 

  • Export your Flow
  • Edit the 'Definition.json' in the export zip package to remove the output fields you want to make non-required from the "required" property of the 'For a selected item' trigger 
  • Re-import the Flow package

This makes the fields optional when the end user triggers the Flow.

 

Just be aware that the 'For a selected item' trigger will not pass any fields that were left blank into the Flow. So, your Flow needs to check for the presence of a field in the trigger output (using a contains()) before attempting to manipulate the field contents.

7 REPLIES 7
v-yamao-msft
Community Support
Community Support

Hi @StevenWade,

 

Thanks for sharing.

It seems that what you shared works perfectly.

 

Best regards,

Mabel Mao

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

Thanks! Was just sharing here in case others had the same issue.

Thank you for this - was searching for this very thing and ran across your article.

beginAgain
Advocate I
Advocate I

Hello,

 

I am able to alter the JSON file ok and that works great and I have 3 optional emails now in my flow. I understand what he means when he says "Just be aware that the 'For a selected item' trigger will not pass any fields that were left blank into the Flow." So how do I check that a field doesn't exist in the trigger output? In a condition I have tried:

 

@contains(triggerBody(), triggerBody()?['email'])

AND

@contains(triggerBody()?['entity']?['value'], triggerBody()?['email'])

 

So bottom line I just need help with figuring out how to tell if the field (in this case email) object is missing from the "For a selected item" object

 

 Anyone have any ideas? Any help will be appreciated

 

Thank you

Got the correct syntax from @StevenWade

 

My expression was too complex I guess, the below worked for me.

 

@contains(triggerBody(), '[email]')

 

He also referenced another article that says this will work:

 

@contains(triggerBody(), 'email')

 

https://powerusers.microsoft.com/t5/Building-Flows/Check-triggerBody-for-existence-of-a-property-wit...

 

HTH - Cheers 🙂

Just be aware that you are looking for a literal text string within the trigger body -- @contains() is not JSON aware. That means you need to ensure some uniqueness within your variable names. In your 'email' example, @contains() would return TRUE if someone populated "email', 'email1', or 'email2'; or, if they just used the word 'email' in one of the text responses. Basing your conditional tests on generic variable names may generate errors or unexpected results.

 

This is a workable hack, and I've used it in several different scenarios. Just make sure you're using unique variable names.

Good advice ty 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,604)