Io: how to set a property to null?

In on premise webMethods I can set a property to $null in a transform pipeline. How do I do this in the cloud version?

Double-click the variable to open the set value dialog. Don’t enter a value, but make sure “Include empty values for string types” is checked.
empyValue

1 Like

That’s not null, that’s an empty string, no?

@bastiaanr – can you clarify exactly where you are specifying $null? This “magic” literal cannot be used to set anything. It can be used to check if a var is null in a BRANCH in some other cases.

Setting a string var to “” is not equivalent to null. Such a var will not match $null.

If you need a var to be in the pipeline and explicitly set to null (which is rare – usually just drop the var) you can create Java service that accepts an input var that holds the name of the variable you want to create with a null value. But really, should just drop the var.

If you have more details about your specific scenario, the guidance can be refined.

2 Likes

Thank you for the answers. I’m talking about the cloud version of webMethods and want to set an attribute to null in a transform pipeline. I want it null because I want that the attribute still exists in the document but has no value. In my preference the existance attributes in a document is the same at runtime and design time.

If empty string works for you, go for it. Using null for a purpose other then checking if it exists or not is usually a bad idea. Even if your document validation requires it, I recommend updating your schema to accept empty string and use it that way. null is not a value, and it shouldn’t be used as value.

1 Like

Sure, but just keep in mind that null and empty string are not the same. As such, a var set to “” will not match $null.