cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

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
Highlighted
Community Support
Community Support

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

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.
Highlighted
Advocate II
Advocate II

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

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

Highlighted
Advocate I
Advocate I

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

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

Highlighted
Advocate I
Advocate I

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

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

Highlighted
Advocate I
Advocate I

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

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 🙂

Highlighted
Advocate II
Advocate II

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

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.

Highlighted
Advocate I
Advocate I

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

Good advice ty 🙂

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (9,822)