File.getSegments(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Method used to return the iterator of segments delimited by a separator.

Separator is included in each segment.

Empty separator is not allowed.

Returns

Iterator

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

None

Module

N/file Module

Since

2019.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.separator

string

required

The separator to use to divide the segments. For example, if you specify a newline character as the separator, this method returns an iterator where each segment is a single line in the file.

2019.1

Errors

Error Code

Message

Thrown If

SSS_INVALID_SEGMENT_SEPARATOR

Segment separator must not be empty.

The options.separator argument is empty.

SSS_INVALID_ARG_TYPE

You have entered an invalid type argument: <passed type argument>

The options.separator argument is not a string.

SSS_MISSING_REQD_ARGUMENT

<name of missing parameter>

A required argument is not passed.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/file Module Script Samples.

          // Add additional code 
... 
var statementFile = context.input.file;

var statementSegmentIterator = statementFile.getSegments({
    separator: '\\|_|/'
}).iterator();
statementSegmentIterator.each(function (segment) {
               
log.debug({
    title: 'STATEMENT TEXT',
    details: segment.value
});

return true;
...
// Add additional code 

        

Related Topics

file.File
N/file Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices