Skip to content

Commit fd7563e

Browse files
Created Scripted Rest Resource to get data from table return as per parameter pass (ServiceNowDevProgram#747)
1 parent e2bcf76 commit fd7563e

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This code will help to query choice table and get the data according to filter. Modify this according to requirement
2+
# References
3+
- Below is the reference of PDI, what is the configuration of choices
4+
![scripted_rest_resource.png](scripted_rest_resource.png)
5+
- Below is the referecnce of PDI resources of Script
6+
![script.png](script.png)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(function process( /*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
2+
3+
var queryParams = request.queryParams;
4+
5+
var grChoice = new GlideRecord('sys_choice');
6+
grChoice.addQuery('name', queryParams.name);
7+
grChoice.addQuery('element', queryParams.element);
8+
grChoice.query();
9+
10+
var filterList = [];
11+
while (grChoice.next()) {
12+
var label = grChoice.getValue("label");
13+
var value = grChoice.getValue("value");
14+
var object = {
15+
code: value,
16+
country: label
17+
};
18+
filterList.push(object);
19+
}
20+
21+
return filterList;
22+
})(request, response);
131 KB
Loading
116 KB
Loading

0 commit comments

Comments
 (0)