[69981 Closed] JavaScript: set a struct parameter to null

Hi there,

I have a service call that takes a struct as one of its parameters.
The parameter is kind of optional so sometimes I’d like to set it to null.
When I do this in JavaScript I get the following error:
"Error: BinMessage.write: Unknown type of CustomerInformation - TrecCustomer"
It seems like on the client side the library is not able to appropriately serialize the null value.
Is it possible for the JavaScript client library to pass a null value for a struct parameter and if so can you tell me how to achieve that?
Thanks in advance!

Best regards,
Simon

Thanks, logged as bugs://69981: BinMessage doesn’t serialize null value for structs

Simon, thanks for your report, I’ll post the fix here when it’s ready.

Great, thanks for the quick respsone Valeriy.

bugs://69981 got closed as fixed for release DA8.2

here’s the fix - replace the beginning of RemObjects.SDK.BinMessage.prototype.write with:

RemObjects.SDK.BinMessage.prototype.write = function write(aName, aType, aValue) {

if (RemObjects.SDK.RTTI[aType]) {
    if (aValue instanceof RemObjects.SDK.ROComplexType) { //not null
        if (!(aValue instanceof RemObjects.SDK.ROEnumType)) {
            this.fRequestObject += this.parser.encodeInt(1, 8, false);
            if (aValue instanceof RemObjects.SDK.ROStructType)
                this.writeStrWithLength(aType);
            if (aValue instanceof RemObjects.SDK.ROArrayType)
                this.fRequestObject += this.parser.encodeInt(aValue.items.length, 32, false);
        };
        aValue.writeTo(this);
    } else { //null
        if (!(RemObjects.SDK.RTTI[aType].prototype instanceof RemObjects.SDK.ROEnumType)) {
            this.fRequestObject += this.parser.encodeInt(0, 8, false);
            if (RemObjects.SDK.RTTI[aType].prototype instanceof RemObjects.SDK.ROStructType)
                this.writeStrWithLength(aType);
        };
    };
} else
switch (aType) {

and in RemObjects.SDK.BinMessage.prototype.read

value.readFrom(this); } else { //not assigned //<<added value = null; //<<added }; } else { value.readFrom(this); };