Thursday, November 8, 2018

Split a string delimited with ASCII character 5 for XML or SOAP parsing

For transactions with serialized items, the serial number field value may be delimited by ASCII character 5. This happens when the serial numbers are separately entered on each line with a trailing carriage return. The resulting string will be like the following:

10000000000581000000000059

Take note that even if the delimiter is rendered as a '|', the ASCII character value is still 5 and not the usual pipe character ASCII value (124).  A good way to split the string is to first replace the 0x05 character with a pipe, like so:

var serial = nlapiGetLineItemValue('item', 'serialnumbers', line_number);serial = serial.replace(/[\x00-\x1f]/g,'|');

No comments:

Post a Comment