Skip to content

Create script for concatenating #1596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions script for concatenating
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function execute(inputs, outputs) {
function jsonEncode(str) {
var stri = new JSON().encode(str);
return stri.substring(1, stri.length - 1);
}

var remarks = '';
var target = new GlideRecord('incident');
target.addQuery('number', inputs.number);
target.query(); // Issue the query to the database to get relevant records
while (target.next()) {

remarks = remarks + "Priority : " + target.priority.getDisplayValue();

if (target.u_incident_manager_required) {
remarks = remarks + "\\r\\nIncident Manager Requested = Yes";
remarks = remarks + "\\r\\nReason for Incident Manager requested = " + jsonEncode(target.u_reason_for_incident_manager + '');
}

if (target.u_escalation) {
remarks = remarks + "\\r\\nEscalation = Yes";
remarks = remarks + "\\r\\nReason for escalation = " + jsonEncode(target.u_escalation_reason + '');
}
var grWorknotes = new GlideRecord('sys_journal_field');
grWorknotes.addQuery('element_id', inputs.journalid);
grWorknotes.addQuery('element', 'work_notes');
grWorknotes.addEncodedQuery('sys_updated_by!=test_API^sys_updated_by!=system');
grWorknotes.orderByDesc('sys_created_on');

grWorknotes.query();
if (grWorknotes.next()) {
if (inputs.work_notes) {
remarks = remarks + "\\r\\nWork Notes : " + jsonEncode(grWorknotes.value.toString());
}
}



var grComments = new GlideRecord('sys_journal_field');
grComments.addQuery('element_id', inputs.journalid);
grComments.addQuery('element', 'comments');
grComments.orderByDesc('sys_created_on');

grComments.query();
if (grComments.next()) {
if (inputs.comments) {
remarks = remarks + "\\r\\nAdditional comments : " + jsonEncode(grComments.value.toString());
}
}
}
if (!inputs.journalid) {
remarks = inputs.work_notes;
}
outputs.remark = remarks;

})(inputs, outputs);
Loading