-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetTableColumnsClientSide.js
43 lines (40 loc) · 1.7 KB
/
getTableColumnsClientSide.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var getTableColumnsClientSide = Class.create();
getTableColumnsClientSide.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getColumns: function(tableName, encodedQuery, columns) {
var returnData = [];
var mappCol = columns.split(',');
var fetchColumn = new GlideRecord(tableName);
fetchColumn.addEncodedQuery(encodedQuery);
fetchColumn.setLimit(1); //Fetch only one record {Check the Query if it return wrong data}
fetchColumn.query();
if (fetchColumn.next()) {
for (var i = 0; i < mappCol.length; i++) {
var itemCol = {};
itemCol[mappCol[i]] = fetchColumn.getValue(mappCol[i].toString());
returnData.push(itemCol);
}
}
return JSON.stringify(returnData);
},
getColumnsClient: function() {
var tableName = this.getParameter('sysparm_tableName');
var encodedQuery = this.getParameter('sysparm_encodedQuery');
var columns = this.getParameter('sysparm_columns');
var returnData = [];
var mappCol = columns.split(',');
var fetchColumn = new GlideRecord(tableName);
fetchColumn.addEncodedQuery(encodedQuery);
fetchColumn.setLimit(1); //Fetch only one record {Check the Query if it return wrong data}
fetchColumn.query();
if (fetchColumn.next()) {
gs.log('found record');
for (var i = 0; i < mappCol.length; i++) {
var itemCol = {};
itemCol[mappCol[i]] = fetchColumn.getValue(mappCol[i].toString());
returnData.push(itemCol);
}
}
return JSON.stringify(returnData);
},
type: 'getTableColumnsClientSide'
});