Parameter is the ID of the ticket record
function getNotesData(noteIds) {
try {
let columns = [
search.createColumn({
name: “notedate”,
join: “userNotes”,
label: “Date”
}),
search.createColumn({
name: “author”,
join: “userNotes”,
label: “Author”
}),
search.createColumn({
name: “title”,
join: “userNotes”,
label: “Title”
}),
search.createColumn({
name: “note”,
join: “userNotes”,
label: “Memo”
}),
search.createColumn({
name: “direction”,
join: “userNotes”,
label: “Direction”
}),
search.createColumn({
name: “notetype”,
join: “userNotes”,
label: “Type”
})
]
let ticketNoteDetails = search.create({
type: “customrecord_jj_stor_custmr_req_ahap1473”,
filters: [
[“internalidnumber”, “equalto”, noteIds]
],
columns: columns
});
let notesData = [];
ticketNoteDetails.run().each(function (result) {
notesData.push({
date: result.getValue(result.columns[0]),
author: result.getText(result.columns[1]),
title: result.getValue(result.columns[2]),
memo: result.getValue(result.columns[3]),
direction: result.getValue(result.columns[4]),
type: result.getValue(result.columns[5])
});
return true;
});
let validNotes = notesData.filter(note => note.date && note.date.toString().trim() !== “”);
return validNotes.length > 0 ? validNotes : [];
} catch (e) {
log.error(“Error in getNotesData”, e);
return [];
}
}