Skip to content

Instantly share code, notes, and snippets.

View manvillej's full-sized avatar

Jeff Manville manvillej

View GitHub Profile
/**
* Does the work on each loop.
* @param {Number} [limit=10] - The number of records to process per loop.
* @param {Number} [currentNumber=0] - The number of records that have been processed so far, by all previous loops.
*/
function eventWrapper(limit, currentNumber) {
var EVENT_NAME = 'EVENT.NAME.HERE'; //todo: Update this to the name of the event you've created.
var TABLE_NAME = 'TABLE_NAME_HERE'; //todo: Update this to the name of the table containing the records you're processing
var QUERY = 'some_query=here'; //todo: Put your query here
@manvillej
manvillej / example.yml
Created September 9, 2023 13:36
Example YML
Example1:
type: A
field:
Example2:
type: A
field: 2
Example3:
type: B
var ATFGraphQLAPI = {
atfTestToJson: function(test){
return {
"active": test.getDisplayValue("active"),
"sys_id": test.getValue("sys_id"),
"name": test.getValue("name"),
"description": test.getValue("description")
};
},
atfTestResultToJson: function(testResult){
(function process(/*ResolverEnvironment*/ env) {
var suite_id = env.getSource().sys_id.value;
var test_list_object = [];
var test;
var tests_in_suite = new GlideRecord("sys_atf_test_suite_test");
tests_in_suite.addEncodedQuery("test_suite=" + suite_id);
tests_in_suite.query();
(function process(/*ResolverEnvironment*/ env) {
var suite = new GlideRecord("sys_atf_test_suite");
var sys_id = env.getArguments().id;
if(suite.get(sys_id)){
return ATFGraphQLAPI.atfTestToJson(suite);
}
return;
})(env);
schema {
query: Query
}
type Query {
atfTestSuite(id: String!): atfTestSuite
atfTest(id: String!): atfTest
}
type atfTestSuite {
@manvillej
manvillej / ATFGraphQLAPI.js
Last active April 18, 2021 13:33
version 2.0 with Test results
var ATFGraphQLAPI = {
atfTestToJson: function(test){
return {
"active": test.getDisplayValue("active"),
"sys_id": test.getValue("sys_id"),
"name": test.getValue("name"),
"description": test.getValue("description")
};
},
atfTestResultToJson: function(testResult){
(function process(/*ResolverEnvironment*/ env) {
gs.info("getSource: " + JSON.stringify(env.getSource())); // sys_id
gs.info("getArguments: " + JSON.stringify(env.getArguments())); // limit
var limit = parseInt(env.getArguments().limit);
var test_id = env.getSource();
var test_result = new GlideRecord("sys_atf_test_result");
if(limit || limit>0) {
test_result.setLimit(limit);
@manvillej
manvillej / atfTest2.gql
Last active April 17, 2021 16:42
version two of the atf GraphQL API
schema {
query: Query
}
type Query {
atfTest(id: String!): atfTest
}
type atfTest {
active: Boolean
// Script include: ATFGraphQLAPI
var ATFGraphQLAPI = {
"""
takes a glide record object and returns the data structure for an atfTest Schema object.
"""
atfTestToJson: function(test) {
return {
"active": test.getDisplayValue("active"),
"sys_id": test.getValue("sys_id"),
"name": test.getValue("name"),