Configure defaults for the parameter element in the FlowCallout policy

Hi all,

I think it would be a nice addition to be able to set a default value when specifying Parameters for the FlowCallout policy.

Right now there are 2 ways of (cleanly) passing a variable to a shared flow in the FlowCallout:

1. Reference to a variable in the element content:

 

<Parameter name="my-param">{my-var}</Parameter>​

 

2. Reference to a variable in the "ref" field:

 

<Parameter name="my-param" ref="my-var"/>​

 

 

But when developing with a lot of shared flows in sequence, it happens a lot that certain variables not always get written a value to, causing them to be null which in turn results in a runtime error on the FlowCallout policy. It would be nice to be able to set a default value to prevent your FlowCallout policy from breaking so easily.

So my suggestion would be to allow us to specify a default value when configuring a FlowCallout policy. Where I could configure my policy to look something like this:

 

 

<Parameter name="my-param" ref="my-optional-var">default-value</Parameter>

 

 

The way this could work is to give precedence to the "ref" field, if that variable cannot be resolved the policy will proceed with the value that is inside the element.

Another way would be to just add a "default" field that is read from if the otherwise specified variable cannot be resolved.

 

I think it would be a nice quality-of-life addition to the policy. Always having to think about handling unset variables in a separate policy is less than desired in my opinion. 
What do you guys think about this?

 

Kind regards,
Piet

Solved Solved
3 2 204
1 ACCEPTED SOLUTION

Hi Piet

You can do what you want now, I think, with this syntax. 

 

<FlowCallout name='FC-Parameterized-Callout-2'>
  <Parameters>
    <!-- with this syntax you can specify a default value -->
    <Parameter name='param1'>{firstnonnull(variable1,'DEFAULT')}</Parameter>
    <Parameter name='param2'>{messageid}</Parameter>
  </Parameters>
  <SharedFlowBundle>example-parameterized-callout</SharedFlowBundle>
</FlowCallout>

 

The documentation for that firstnonnull magic is here.

I agree with you that this syntax:

<Parameter name="my-param" ref="my-optional-var">default-value</Parameter>

...should ideally behave as you described - it should use the referenced variable if available, otherwise the default value.  That seems like a usability bug at the very least. 

View solution in original post

2 REPLIES 2

Hi Piet

You can do what you want now, I think, with this syntax. 

 

<FlowCallout name='FC-Parameterized-Callout-2'>
  <Parameters>
    <!-- with this syntax you can specify a default value -->
    <Parameter name='param1'>{firstnonnull(variable1,'DEFAULT')}</Parameter>
    <Parameter name='param2'>{messageid}</Parameter>
  </Parameters>
  <SharedFlowBundle>example-parameterized-callout</SharedFlowBundle>
</FlowCallout>

 

The documentation for that firstnonnull magic is here.

I agree with you that this syntax:

<Parameter name="my-param" ref="my-optional-var">default-value</Parameter>

...should ideally behave as you described - it should use the referenced variable if available, otherwise the default value.  That seems like a usability bug at the very least. 

Just tested and this works great. Thank you!