Suitescript: Error using financial institution connectivity script and CAMT053 parser on NetSuite

Hope you are able to assist.
On NetSuite, I am currently building a financial institution connectivity script with the sole goal of passing an XML file to the ‘CAMT053 Plugin Implementation’ which is part of the bank parser bundle. I am unsure on how the plug-in processes XML files; even more challenging is we do not have access to the scripts to review what could be going wrong.

Anyhow, here is a snippet of my code:

    function getTransactionData(context) {
    var configurationId = context.pluginConfiguration.getConfigurationFieldValue({ fieldName: "configuration_id" });
    var configuration = loadConfiguration(configurationId)

    var accountRequests = JSON.parse(context.accountRequestsJSON);
    nLog.audit({
        title: 'accountRequests',
        details: JSON.stringify(context.accountRequestsJSON)
    });

    if (accountRequests != null) {
        accountRequests.forEach(function (accountRequest) {
               var accountId = accountRequest.accountMappingKey;
               var fromDateTime = accountRequest.dataStartTime;
               var toDateTime = accountRequest.dataEndTime;
               
               //LOAD FILE
               let fileTestLoad = nFile.load({
                   id: 12345
               });

               //CAPTURE XML CONTENT AS A STRING
               var downloadedData = fileTestLoad.getContents();

               //PASS STRING, GET PROCESSED BY CAMT053 PARSER (provided by NetSuite)
               context.addDataChunk({dataChunk: downloadedData});

            }

        });
    }
    context.returnAccountRequestsJSON({ accountsJson: context.accountRequestsJSON });
}

Right now, I am receiving this error:
The file could not be parsed or imported, because of the following error:
{“type”:”error.SuiteScriptError”,”name”:”SSS_XML_DOM_EXCEPTION”,”message”:”The processing instruction target matching “[xX][mM][lL]” is not allowed. [line 221, column 17]”,”id”:””,”stack”:[“fromString(N/xml)”,”(/SuiteBundles/Bundle 293699/com.netsuite.bsp/src/wrapper/bsp_wrapper_xml.js:10)”,”(/SuiteBundles/Bundle 293699/com.netsuite.bsp/src/parser/bsp_parser_camt053.js:629)”],”cause”:{“type”:”internal error”,”code”:”SSS_XML_DOM_EXCEPTION”,”details”:”The processing instruction target matching “[xX][mM][lL]” is not allowed. [line 221, column 17]”,”userEvent”:null,”stackTrace”:[“fromString(N/xml)”,”(/SuiteBundles/Bundle 293699/com.netsuite.bsp/src/wrapper/bsp_wrapper_xml.js:10)”,”(/SuiteBundles/Bundle 293699/com.netsuite.bsp/src/parser/bsp_parser_camt053.js:629)”],”notifyOff”:false},”notifyOff”:false,”userFacing”:false}

I did some research on this error; apparently occurs when the XML file includes an incorrect XML declaration or incorrect format. This has indeed been reviewed, and used an online validator and all seems fine. Here’s a snippet of the XML file I am using:

To summarise – I want to understand how to use the context.addChunks() call with NetSuite’s default CAMT053 parser that comes from the bank parser bundle. Any assistance is most appreciated!

How to trigger script: I simply EDIT/SAVE the format profile record:

UPDATE: I try to convert the string back to XML before passing it to the ADDCHUNKS() call, and also revert it back to string (just to test the contents are fine. Something seems to go wrong when passed to the parser. Here’s a snippet of what I was testing:

            var downloadedData = fileTestLoad.getContents().replace(/<?[^>]+?>/, '').trim(); 
            log.debug('data before any change', downloadedData);
            var data2 = nXml.Parser.fromString({text: downloadedData}); //<--- This works fine
            log.debug('str to xml success!', data2); 
            var data3 = nXml.Parser.toString({document: data2}); //<--- This works fine
            log.debug('xml to str success!', data3);
            context.addDataChunk({dataChunk: downloadedData}); //<--- something goes wrong...

It looks like you are trying to create your own FI Connectivity Plugin.

I had a somewhat similar use case where I needed to process ZBA transactions from our ABSI bank files. I ended up just creating my own BAI2 parser as an FI Parser Plugin.

Your code doesn’t implement any sort of connection so I am guessing you are more interested in the parser side of things than in the connectivity.

However to get what you are doing to work you could just strip the PI from the xml file contents.

var downloadedData = fileTestLoad.getContents().replace(/<?[^>]+?>/, '').trim();

That still leaves you though with implementing the actual connectivity.

Also if you are having XML parsing issues your best bet is posting the xml here. We don’t even know if NetSuite is using its own N/xml.parser in this module. Also just a reminder that each .addDataChunks call is limited to 25-million characters. If you are dealing with a large file you’ll have to manually chunk it. One of the ways you could be getting the ‘well formed’ exception is if your file is larger than the addDataChunk limit then NetSuite may be trying to process only part of a file. In addition to the addDataChunks limitation N/file.getContents only returns up to 10MB (or roughly 1.2M characters). Your parsing of downloadedData seems to indicate the file isn’t being broken by that but thought it should be mentioned.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật