How do you deal with boolean ?

Hi,

In a service Java I can return a Boolean to the Pipeline, and then I debug mode I can observe the “T/F” icon for the bool attribute.

How are you considering these boolean attribute, do you use it ? What is the best usage/recommendations ?

I’m asking you this question because in most of the examples I’ve seen (ex : PSUtilties, WmPublic) , they use a string return value: ‘true’ or ‘false’ and not a bool one.

Regards

If you are working with Flow just use String. If you are working in Java.NET\C++ in webMethods then use the right data types for fields. At least that is what my experience taught me.

Hi,

Thanks for your reply, but when you do Java and Flow Service you would use the 1 or the 2 ?

Boolean isExist = true;

1- IDataUtil.put(idc, “isExist”, String.valueOf(isExist));

2- IDataUtil.put(idc, “isExist”, isExist);

Regards

It needs to end up as a string in Flow so your Java service will output the variable as string. Option 1.

Hi,

I think that it is possible to go for the boolean data type even in flow services.

Just compare them against “true” or “false”, the neccessary conversions will be made internally.

Additionally the field of type boolean will have a pick list when defining a value for it, which only allows true or false as values.
This also improves the readability of the service as it is visible that this is a boolean and not just a string.

See Working_With_Designer Guide and/or Service_Development_Help for further informations.

Regards,
Holger

I believe that will be no different than comparing strings in Flow. Its not like you can branch on a Boolean variable with the control going to default sequence if the variable is false.

Imagine you have a branch on Boolean variable with two sequences under it where one has a label of false and another as a default. If the Boolean variable is false then the Flow will not go to default but it will go to the sequence with label as “false”. It is still reading it as a string rather than boolean. If Flow recognizes the Boolean data type then the control will go to the default sequence rather than the “false” sequence.

I hope that was not confusing :wink:

In this case it might be better to label the sequences as false and true.

A third possibility might be the label $null, if the variable has not been initialized.
But this is a rare occasion as this can only happen when the boolean field is an input field of the service which was not set by the caller.

Regards,
Holger