Skip to content
Closed
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions Background Scripts/Get XML Of a Record/getRecordXML.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function getRecordXML(tableName, sysId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking a table name and sys id, consider taking a GlideRecord as the input. Then you could use it in a business rule by feeding it current.

var gr = new GlideRecord(tableName); // Replace 'incident' with your table name
gr.get(sysId);
var xmlDoc = new XMLDocument();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of building the xml manually, there is an object to xml script available out of the box.

var baseTag = xmlDoc.createElement('incident');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the table name, not static value of incident?

var fields = gr.getFields();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a valid glide record method. There is a get fields method in glide record util.


var fieldNames = [];
for (var i = 0; i < fields.size(); i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is fields.size()?

fieldNames.push(fields.get(i).getName());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is fields.get(i).getName()?

}
fieldNames.sort();

fieldNames.forEach(function(fieldName) {
var fieldValue = gr.getValue(fieldName);
var fieldTag = xmlDoc.createElement(fieldName);
fieldTag.setTextContent(fieldValue);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a documented method.

baseTag.appendChild(fieldTag);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a documented method

});
gs.info(xmlDoc.toString());
return xmlDoc.toString();
}
1 change: 1 addition & 0 deletions Background Scripts/Get XML Of a Record/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This function, getRecordXML, is a custom JavaScript function designed for ServiceNow to generate an XML representation of a record in any specified table.
10 changes: 10 additions & 0 deletions UI Actions/Open LIST UI Action/UIActionscript.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an unintended file

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function openinLIST() {
var taskTable = g_form.getTableName();

// Construct the hardcoded LIST URL
var listURL = '/' + taskTable + '_list.do?sysparm_clear_stack=true';

// Open in new window
var w = getTopWindow();
w.window.open(listURL, '_blank');
}
2 changes: 2 additions & 0 deletions UI Actions/Open LIST UI Action/readme.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an unintended file

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This UI Action opens the LIST view for the current table in another tab.
UI action will run on Onclick openinLIST()
Loading