- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 08:23 AM - edited 08-29-2024 08:27 AM
<c SEGMENT="1">
<a> val_A1</a>
<d> val_D1</d>
</c>
<c SEGMENT="2">
<a> val_A2</a>
<b> val_B2</b>
</c>
<c SEGMENT="3">
<a> val_A3</a>
</c>
<b> val_D</d>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 05:05 AM
Hi All,
I have fouond a solution to the reported problem,
I used a Data Source with Type "Custom (Load by Script)", using the Data Loader Script I read the attached XML file and transform it in a JSON form,
now I'm able the design a code that will extrad into the Import set only the colum that I need
here the code:
(function loadData(import_set_table, data_source, import_log, last_success_import_time) {
var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments(data_source.getTableName(), data_source.getUniqueValue());
while (agr.next()) {
var agrValue = attachment.getContentStream(agr.getUniqueValue());
var reader = new GlideTextReader(agrValue);
var txtFull = '';
do{
var txtRow = reader.readLine();
if (txtRow){
txtFull+=txtRow;
}
}while (txtRow != null);
gs.log('Fulltxt = ' +txtFull, 'DataSourceLoader');
var helper = new XMLHelper(txtFull);
var json_obj = helper.toObject();
gs.log('JSON value = ' + JSON.stringify(json_obj,null,3), 'DataSourceLoader');
}
})(import_set_table, data_source, import_log, last_success_import_time);
Regards
Vincenzo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 05:05 AM
Hi All,
I have fouond a solution to the reported problem,
I used a Data Source with Type "Custom (Load by Script)", using the Data Loader Script I read the attached XML file and transform it in a JSON form,
now I'm able the design a code that will extrad into the Import set only the colum that I need
here the code:
(function loadData(import_set_table, data_source, import_log, last_success_import_time) {
var attachment = new GlideSysAttachment();
var agr = attachment.getAttachments(data_source.getTableName(), data_source.getUniqueValue());
while (agr.next()) {
var agrValue = attachment.getContentStream(agr.getUniqueValue());
var reader = new GlideTextReader(agrValue);
var txtFull = '';
do{
var txtRow = reader.readLine();
if (txtRow){
txtFull+=txtRow;
}
}while (txtRow != null);
gs.log('Fulltxt = ' +txtFull, 'DataSourceLoader');
var helper = new XMLHelper(txtFull);
var json_obj = helper.toObject();
gs.log('JSON value = ' + JSON.stringify(json_obj,null,3), 'DataSourceLoader');
}
})(import_set_table, data_source, import_log, last_success_import_time);
Regards
Vincenzo