Initial Commit
This commit is contained in:
15
.vscode/settings.json
vendored
Normal file
15
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"files.exclude": {
|
||||||
|
"*/system": true,
|
||||||
|
"system" : true,
|
||||||
|
"node_modules": true,
|
||||||
|
".vscode": true,
|
||||||
|
"lib": true,
|
||||||
|
"tsconfig.json": true
|
||||||
|
},
|
||||||
|
"search.exclude": {
|
||||||
|
"*/system": true
|
||||||
|
},
|
||||||
|
"css.lint.emptyRules": "ignore",
|
||||||
|
"html.customData": ["./lib/data/jelly_schema.json"]
|
||||||
|
}
|
||||||
57
Fulfilment Automater/.eslintrc
Normal file
57
Fulfilment Automater/.eslintrc
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"constructor-super": "warn",
|
||||||
|
"no-case-declarations": "warn",
|
||||||
|
"no-class-assign": "warn",
|
||||||
|
"no-compare-neg-zero": "warn",
|
||||||
|
"no-cond-assign": "warn",
|
||||||
|
"no-console": "warn",
|
||||||
|
"no-const-assign": "warn",
|
||||||
|
"no-constant-condition": "warn",
|
||||||
|
"no-control-regex": "warn",
|
||||||
|
"no-debugger": "warn",
|
||||||
|
"no-delete-var": "warn",
|
||||||
|
"no-dupe-args": "warn",
|
||||||
|
"no-dupe-class-members": "warn",
|
||||||
|
"no-dupe-keys": "warn",
|
||||||
|
"no-duplicate-case": "warn",
|
||||||
|
"no-empty-character-class": "warn",
|
||||||
|
"no-empty-pattern": "warn",
|
||||||
|
"no-empty": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
"allowEmptyCatch": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"no-ex-assign": "warn",
|
||||||
|
"no-extra-boolean-cast": "warn",
|
||||||
|
"no-extra-semi": "warn",
|
||||||
|
"semi": "warn",
|
||||||
|
"no-fallthrough": "warn",
|
||||||
|
"no-func-assign": "warn",
|
||||||
|
"no-global-assign": "warn",
|
||||||
|
"no-inner-declarations": "warn",
|
||||||
|
"no-invalid-regexp": "warn",
|
||||||
|
"no-irregular-whitespace": "warn",
|
||||||
|
"no-mixed-spaces-and-tabs": "warn",
|
||||||
|
"no-new-symbol": "warn",
|
||||||
|
"no-obj-calls": "warn",
|
||||||
|
"no-octal": "warn",
|
||||||
|
"no-redeclare": "warn",
|
||||||
|
"no-regex-spaces": "warn",
|
||||||
|
"no-self-assign": "warn",
|
||||||
|
"no-sparse-arrays": "warn",
|
||||||
|
"no-this-before-super": "warn",
|
||||||
|
"no-undef": "off",
|
||||||
|
"no-unexpected-multiline": "warn",
|
||||||
|
"no-unreachable": "warn",
|
||||||
|
"no-unsafe-finally": "warn",
|
||||||
|
"no-unsafe-negation": "warn",
|
||||||
|
"no-unused-labels": "warn",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"no-useless-escape": "warn",
|
||||||
|
"require-yield": "warn",
|
||||||
|
"use-isnan": "warn",
|
||||||
|
"valid-typeof": "warn"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
Fulfilment Automater/app.config.json
Normal file
5
Fulfilment Automater/app.config.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"CustomFileTypes": {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Fulfilment Automater/background scripts/script.js
Normal file
1
Fulfilment Automater/background scripts/script.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
// Write your scripts here to run (JavaScript executed on server)
|
||||||
@ -0,0 +1 @@
|
|||||||
|
53faebf397e461105838bfb3f153af54
|
||||||
@ -0,0 +1 @@
|
|||||||
|
8f8abaa29713111093a8337e6253af46
|
||||||
@ -0,0 +1 @@
|
|||||||
|
db8a7a629713111093a8337e6253af94
|
||||||
@ -0,0 +1 @@
|
|||||||
|
bb1967bf97a461105838bfb3f153afa6
|
||||||
@ -0,0 +1 @@
|
|||||||
|
5745eb4b975021105838bfb3f153afc7
|
||||||
@ -0,0 +1 @@
|
|||||||
|
e84b76a29713111093a8337e6253afa4
|
||||||
@ -0,0 +1 @@
|
|||||||
|
55c87bf3972861105838bfb3f153af2a
|
||||||
@ -0,0 +1 @@
|
|||||||
|
e229f7f3972861105838bfb3f153af88
|
||||||
@ -0,0 +1 @@
|
|||||||
|
7333733f97e461105838bfb3f153afa0
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
|
||||||
|
if (newValue === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Type appropriate comment here, and begin script below
|
||||||
|
var ga = new GlideAjax("CoreClientUtils");
|
||||||
|
ga.addParam("sysparm_name", "getCatalogItemTargetTable");
|
||||||
|
ga.addParam("sysparm_catalogItemID", newValue);
|
||||||
|
ga.getXMLAnswer(function(answer){
|
||||||
|
if(answer){
|
||||||
|
g_form.setValue("condition_table", answer);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
|
||||||
|
if (isLoading || newValue === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Type appropriate comment here, and begin script below
|
||||||
|
switch(newValue){
|
||||||
|
case "service_catalog_item":
|
||||||
|
g_form.setValue("run_on_table", "sc_req_item");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_form.setValue("run_on_table", "task");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('dynamic_approval', false);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('dynamic_approval', true);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('group_approval', false);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('group_approval', true);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('user_approval', false);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onCondition() {
|
||||||
|
g_form.setSectionDisplay('user_approval', true);
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
efbaebf397e461105838bfb3f153af26
|
||||||
@ -0,0 +1 @@
|
|||||||
|
5f15ebcb975021105838bfb3f153af66
|
||||||
@ -0,0 +1 @@
|
|||||||
|
9de867bf97a461105838bfb3f153afb3
|
||||||
1
Fulfilment Automater/src/Data Model/Tables/Log.table.now
Normal file
1
Fulfilment Automater/src/Data Model/Tables/Log.table.now
Normal file
@ -0,0 +1 @@
|
|||||||
|
4d1bbae29713111093a8337e6253affd
|
||||||
@ -0,0 +1 @@
|
|||||||
|
e50aafb397e461105838bfb3f153afbb
|
||||||
@ -0,0 +1 @@
|
|||||||
|
6a98b7f3972861105838bfb3f153af4e
|
||||||
@ -0,0 +1 @@
|
|||||||
|
1a193337972861105838bfb3f153afad
|
||||||
@ -0,0 +1 @@
|
|||||||
|
5c23333f97e461105838bfb3f153affa
|
||||||
@ -0,0 +1 @@
|
|||||||
|
7c0266bc97b021105838bfb3f153af5b
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
|
||||||
|
<j:set var="jvar_n" value="create_new_fp_${ref}"/>
|
||||||
|
<span id="${jvar_n}" onclick="createNewFP('${ref}')" title="Create new Fulfillment Plan" alt="Create new" tabindex="0" class="btn btn-default icon-open-document-new-tab">
|
||||||
|
<span class="sr-only">Create new FP</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function createNewFP(reference) {
|
||||||
|
var currentTable = g_form.getTableName();
|
||||||
|
var type;
|
||||||
|
switch(currentTable){
|
||||||
|
case "x_355681_fa_service_catalog_trigger":
|
||||||
|
type = "service_catalog_item"
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
type = "task_table";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.open("/x_355681_fa_fulfillment_plan.do?sysparm_query_override=run_on_table=" + g_form.getValue('condition_table') + "^type=" + type, '_blank');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</j:jelly>
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
|
||||||
|
|
||||||
|
// implement resource here
|
||||||
|
var tableName = request.pathParams.tableName;
|
||||||
|
var body = {
|
||||||
|
tables:[]
|
||||||
|
};
|
||||||
|
var table = new GlideTableHierarchy(tableName);
|
||||||
|
var extensionTables = table.getAllExtensions();
|
||||||
|
var dbGr = new GlideRecord('sys_db_object');
|
||||||
|
dbGr.addQuery("name", "IN", extensionTables);
|
||||||
|
dbGr.orderBy("label");
|
||||||
|
dbGr.query();
|
||||||
|
while(dbGr.next()){
|
||||||
|
body.tables.push({
|
||||||
|
name: dbGr.getValue("name"),
|
||||||
|
label: dbGr.getValue("label")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setContentType('application/json');
|
||||||
|
response.setStatus(200);
|
||||||
|
response.setBody(body.tables);
|
||||||
|
})(request, response);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function calculatedFieldValue(current) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
return ''; // return the calculated value
|
||||||
|
|
||||||
|
})(current);
|
||||||
@ -0,0 +1 @@
|
|||||||
|
0b9919b997b061105838bfb3f153afca
|
||||||
@ -0,0 +1 @@
|
|||||||
|
f7d955b997b061105838bfb3f153af21
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function executeRule(current, previous /*null when async*/) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
var coreUtils = new CoreUtils();
|
||||||
|
coreUtils.LOG.debug("Task number: " + current.task.number + " picked up by FA.");
|
||||||
|
})(current, previous);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function executeRule(current, previous /*null when async*/) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
var coreUtils = new CoreUtils();
|
||||||
|
coreUtils.LOG.debug("Task number: " + current.task.number + " picked up by FA.");
|
||||||
|
})(current, previous);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
(function executeRule(current, previous /*null when async*/) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
var coreUtils = new CoreUtils();
|
||||||
|
coreUtils.LOG.debug("Task number: " + current.getValue("number") + " picked up by FA.");
|
||||||
|
})(current, previous);
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
(function executeRule(current, previous /*null when async*/) {
|
||||||
|
|
||||||
|
// Add your code here
|
||||||
|
var triggerUtils = new TriggerUtils();
|
||||||
|
triggerUtils.refreshConditionTable();
|
||||||
|
|
||||||
|
})(current, previous);
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
var CoreClientUtils = Class.create();
|
||||||
|
CoreClientUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
|
||||||
|
coreUtils: new CoreUtils(),
|
||||||
|
saveProperty: function(){
|
||||||
|
var answer = false;
|
||||||
|
var property = this.getParameter("sysparm_property");
|
||||||
|
var value = this.getParameter("sysparm_value");
|
||||||
|
|
||||||
|
if(property && value){
|
||||||
|
answer = this.coreUtils.saveProperty(property, value);
|
||||||
|
}
|
||||||
|
return JSON.stringify(answer);
|
||||||
|
},
|
||||||
|
|
||||||
|
getCatalogItemTargetTable: function(){
|
||||||
|
var answer = false;
|
||||||
|
var catalogItemID = this.getParameter("sysparm_catalogItemID");
|
||||||
|
|
||||||
|
if(catalogItemID){
|
||||||
|
answer = this.coreUtils.getCatalogItemTargetTable(catalogItemID);
|
||||||
|
}
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'CoreClientUtils'
|
||||||
|
});
|
||||||
|
|
||||||
|
new ProcessorUtils("x_355681_fa").wrapPrototype(CoreClientUtils.prototype);
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
var CoreUtils = Class.create();
|
||||||
|
CoreUtils.prototype = {
|
||||||
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
isFA: function(type){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
let bool = false;
|
||||||
|
switch(type){
|
||||||
|
case "task":
|
||||||
|
var taskTriggerGr = new GlideRecord(FAProperty.table.taskTriggerTable);
|
||||||
|
taskTriggerGr.addQuery("condition_table", current.getTableName());
|
||||||
|
taskTriggerGr.addActiveQuery();
|
||||||
|
taskTriggerGr.orderBy("order");
|
||||||
|
taskTriggerGr.query();
|
||||||
|
while(taskTriggerGr.next()){
|
||||||
|
bool = this._isValidTrigger(taskTriggerGr);
|
||||||
|
if(!bool) continue;
|
||||||
|
|
||||||
|
//We have one plan that will run so we return true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "rp":
|
||||||
|
var catalog_item = current.getValue('producer');
|
||||||
|
current = current.task.getRefRecord(); //Need to overwrite current for GlideFilter
|
||||||
|
//No break cause we continue in the sc case
|
||||||
|
case "sc":
|
||||||
|
var scTriggerGr = new GlideRecord(FAProperty.table.scTriggerTable);
|
||||||
|
scTriggerGr.addQuery("catalog_item", current.cat_item || catalog_item);
|
||||||
|
scTriggerGr.addActiveQuery();
|
||||||
|
scTriggerGr.orderBy("order");
|
||||||
|
scTriggerGr.query();
|
||||||
|
while(scTriggerGr.next()){
|
||||||
|
bool = this._isValidTrigger(scTriggerGr);
|
||||||
|
if(!bool) continue;
|
||||||
|
|
||||||
|
//We have one plan that will run so we return true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.LOG.debug("is it picked up: " + bool);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
answer = bool
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
_isValidTrigger: function(triggerGr){
|
||||||
|
var answer = true;
|
||||||
|
var runCondition = triggerGr.getValue("run_if");
|
||||||
|
if(runCondition){
|
||||||
|
answer = GlideFilter.checkRecord(current, runCondition);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!!triggerGr.script_condition && !!answer){ //casting to boolean
|
||||||
|
var triggerUtils = new TriggerUtils();
|
||||||
|
answer = triggerUtils.runTriggerScript(triggerGr);
|
||||||
|
}
|
||||||
|
//We have one plan that will run so we return true;
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
saveProperty: function(property, value){
|
||||||
|
var answer = false;
|
||||||
|
var propertyGr = new GlideRecord('sys_properties');
|
||||||
|
|
||||||
|
if(propertyGr.get('name', property)){
|
||||||
|
propertyGr.setValue('value', value);
|
||||||
|
answer = propertyGr.update();
|
||||||
|
}
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
getCatalogItemTargetTable: function(catalogItemID){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
var catalogItemGr = new GlideRecord('sc_cat_item');
|
||||||
|
if(catalogItemGr.get(catalogItemID)){
|
||||||
|
var table = catalogItemGr['ref_' + catalogItemGr.getValue('sys_class_name')].table_name;
|
||||||
|
answer = table || "sc_req_item";
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
showUIActionButton: function(table){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
var settings = JSON.parse(gs.getProperty("x_355681_fa.form.admin.settings", "{}"));
|
||||||
|
if(settings.quickActions){
|
||||||
|
var tables = [];
|
||||||
|
var quickActions = settings.quickActions;
|
||||||
|
if(quickActions.taskUiAction){
|
||||||
|
var taskActions = quickActions.task;
|
||||||
|
if(taskActions.allTaskTables){
|
||||||
|
var taskTables = new GlideTableHierarchy("task");
|
||||||
|
tables = tables.concat(taskTables.getAllExtensions());
|
||||||
|
}else{
|
||||||
|
tables = tables.concat(taskActions.taskRelatedTables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(quickActions.serviceCatalogUiAction){
|
||||||
|
var serviceCatalogActions = quickActions.serviceCatalog;
|
||||||
|
if(serviceCatalogActions.allServiceCatalogTables){
|
||||||
|
var serviceCatalogTables = new GlideTableHierarchy("sc_cat_item");
|
||||||
|
tables = tables.concat(serviceCatalogTables.getAllExtensions());
|
||||||
|
}else{
|
||||||
|
tables = tables.concat(serviceCatalogActions.serviceCatalogRelatedTables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gs.info(JSON.stringify(tables))
|
||||||
|
answer = tables.indexOf(table) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'CoreUtils'
|
||||||
|
};
|
||||||
|
new ProcessorUtils("x_355681_fa").wrapPrototype(CoreUtils.prototype);
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
const scope = "x_355681_fa";
|
||||||
|
|
||||||
|
var FAProperty = {
|
||||||
|
table: {
|
||||||
|
scTriggerTable: scope + "_service_catalog_trigger",
|
||||||
|
taskTriggerTable: scope + "_task_trigger"
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
var FulfillmentPlanUtils = Class.create();
|
||||||
|
FulfillmentPlanUtils.prototype = {
|
||||||
|
initialize: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
createNew: function(){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
tester: function(){
|
||||||
|
this.LOG.error("does this work", "tester");
|
||||||
|
this.generateError();
|
||||||
|
},
|
||||||
|
|
||||||
|
generateError: function(){
|
||||||
|
fdsafdasf
|
||||||
|
},
|
||||||
|
|
||||||
|
setFulfillmentPlan: function(id, details = {}){
|
||||||
|
let answer = false;
|
||||||
|
|
||||||
|
let faGr = new GlideRecord("x_355681_fa_fulfillment_plan");
|
||||||
|
if(id) {
|
||||||
|
faGr.addQuery("sys_id", id);
|
||||||
|
}else {
|
||||||
|
for(var key in details){
|
||||||
|
faGr.addQuery(key, details[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
faGr.query();
|
||||||
|
if(faGr.newRecord()){
|
||||||
|
this.fulfillmentPlan = faGr;
|
||||||
|
answer = faGr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function(values){
|
||||||
|
for(let key in values){
|
||||||
|
this.fulfillmentPlan.setValue(key, values[key]);
|
||||||
|
}
|
||||||
|
this.fulfillmentPlan.update();
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'FulfillmentPlanUtils'
|
||||||
|
};
|
||||||
|
|
||||||
|
new ProcessorUtils("x_355681_fa").wrapPrototype(FulfillmentPlanUtils.prototype);
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
var HelperUtils = Class.create();
|
||||||
|
HelperUtils.prototype = {
|
||||||
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
getRecFromAttributes: function(details){
|
||||||
|
var answer = false;
|
||||||
|
var {
|
||||||
|
table,
|
||||||
|
attributes = {}
|
||||||
|
} = details;
|
||||||
|
|
||||||
|
if(!table) return false;
|
||||||
|
|
||||||
|
var recGr = new GlideRecord(table);
|
||||||
|
for(var key in attributes){
|
||||||
|
recGr.addQuery(key, attributes[key]);
|
||||||
|
}
|
||||||
|
recGr.setLimit(1);
|
||||||
|
recGr.query();
|
||||||
|
if(recGr.next()){
|
||||||
|
answer = recGr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'HelperUtils'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var _details = {
|
||||||
|
table: "sys_script_include",
|
||||||
|
attributes: {
|
||||||
|
name: HelperUtils.type
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
new ProcessorUtils('x_355681_fa', _details).wrapClass(HelperUtils);
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
var LogUtils = Class.create();
|
||||||
|
LogUtils.prototype = {
|
||||||
|
source: {},
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
var settings = gs.getProperty("x_355681_fa.form.admin.settings", {});
|
||||||
|
if(settings){
|
||||||
|
settings = JSON.parse(settings);
|
||||||
|
if(settings.logging){
|
||||||
|
this.initializeSettings(settings.logging);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initializeSettings: function(settings){
|
||||||
|
this.enabled = settings.enabled;
|
||||||
|
this.levelDebug = settings.levelOfDebugging;
|
||||||
|
},
|
||||||
|
|
||||||
|
debug: function(message, name, options = {}){
|
||||||
|
if(this.enabled && message && this.levelDebug.debug){
|
||||||
|
var logGr = this._createLogTemplate(message, "debug", {function_name: name, ...this.source});
|
||||||
|
if(logGr){
|
||||||
|
logGr.insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function(message, name, options = {}){
|
||||||
|
if(this.enabled && message && this.levelDebug.error){
|
||||||
|
if(message){
|
||||||
|
var logGr = this._createLogTemplate(message, "error", {function_name: name, ...this.source});
|
||||||
|
if(logGr){
|
||||||
|
logGr.insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
warning: function(message, name, options = {}){
|
||||||
|
if(this.enabled && message && this.levelDebug.warning){
|
||||||
|
var logGr = this._createLogTemplate(message, "warning", {function_name: name, ...this.source});
|
||||||
|
if(logGr){
|
||||||
|
logGr.insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
info: function(message, name, options = {}){
|
||||||
|
if(this.enabled && message && this.levelDebug.info){
|
||||||
|
if(message){
|
||||||
|
var logGr = this._createLogTemplate(message, "info", {function_name: name, ...this.source});
|
||||||
|
if(logGr){
|
||||||
|
logGr.insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_createLogTemplate: function(message, type, values = {}){
|
||||||
|
var logGr = new GlideRecord('x_355681_fa_log');
|
||||||
|
logGr.initialize();
|
||||||
|
logGr.setValue("type", type);
|
||||||
|
logGr.setValue("timestamp", (new Date()).toISOString());
|
||||||
|
logGr.setValue("message", message);
|
||||||
|
logGr.setValue("impacted_record", current.sys_id);
|
||||||
|
if(this._callee){
|
||||||
|
logGr.setValue("debug_information", JSON.stringify(this._callee,undefined,2));
|
||||||
|
}
|
||||||
|
for(var key in values){
|
||||||
|
logGr.setValue(key, values[key]);
|
||||||
|
}
|
||||||
|
return logGr;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'LogUtils'
|
||||||
|
};
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
let LOG;
|
||||||
|
|
||||||
|
var ProcessorUtils = Class.create();
|
||||||
|
ProcessorUtils.prototype = {
|
||||||
|
initialize: function(appScope, details) {
|
||||||
|
if(!appScope) {
|
||||||
|
new LogUtils().write("Application scope undefined.", {type: "error", funcName: "initialize"});
|
||||||
|
}
|
||||||
|
this.internal_scope = appScope;
|
||||||
|
|
||||||
|
if(details){
|
||||||
|
this.details = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
wrapPrototype: function(prototype, options = {}){
|
||||||
|
var {
|
||||||
|
table = "sys_script_include",
|
||||||
|
name = prototype.type,
|
||||||
|
sys_id = false
|
||||||
|
} = options;
|
||||||
|
|
||||||
|
var sourceRecord = this.getSourceRecord(table, { name, sys_id });
|
||||||
|
|
||||||
|
if(!LOG){
|
||||||
|
LOG = new LogUtils();
|
||||||
|
LOG._callee = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var log = LOG;
|
||||||
|
if(sourceRecord){
|
||||||
|
log.source = {
|
||||||
|
source_table: sourceRecord.getTableName(),
|
||||||
|
source_record: sourceRecord.getValue("sys_id")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
prototype.LOG = log;
|
||||||
|
|
||||||
|
Object.getOwnPropertyNames(prototype).forEach(function(f) {
|
||||||
|
if(Object.getOwnPropertyDescriptor(prototype,f).writable){
|
||||||
|
if (typeof prototype[f] === 'function') {
|
||||||
|
|
||||||
|
var func = prototype[f];
|
||||||
|
var funcName = f.toString();
|
||||||
|
prototype[f] = function() {
|
||||||
|
prototype.LOG._callee.unshift({
|
||||||
|
function: funcName,
|
||||||
|
script_include: name,
|
||||||
|
start_time: (new Date()).toISOString()
|
||||||
|
});
|
||||||
|
var returnValue = false;
|
||||||
|
try{
|
||||||
|
returnValue = func.apply(this, arguments);
|
||||||
|
}catch(err){
|
||||||
|
prototype.LOG.error(err.message, funcName);
|
||||||
|
}
|
||||||
|
prototype.LOG._callee.shift();
|
||||||
|
return returnValue;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
LOG = log;
|
||||||
|
},
|
||||||
|
|
||||||
|
getSourceRecord: function(table, options){
|
||||||
|
var answer = false;
|
||||||
|
var { sys_id, name } = options;
|
||||||
|
|
||||||
|
var sourceGr = new GlideRecord(table);
|
||||||
|
if(name) sourceGr.addQuery("name", name);
|
||||||
|
if(sys_id) sourceGr.addQuery("sys_id", sys_id);
|
||||||
|
sourceGr.addQuery("sys_scope.scope", this.internal_scope);
|
||||||
|
sourceGr.query();
|
||||||
|
if(sourceGr.next()){
|
||||||
|
answer = sourceGr;
|
||||||
|
}
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'ProcessorUtils'
|
||||||
|
};
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
var QueueUtils = Class.create();
|
||||||
|
QueueUtils.prototype = {
|
||||||
|
/*
|
||||||
|
* Do not defined LOG in this class. It will be overwritten due to it being an automatically added function by ProcessorUtils
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
writeToQueue: function(event, data){
|
||||||
|
this.tester();
|
||||||
|
this.LOG.debug("write to queue function","writeToQueue");
|
||||||
|
},
|
||||||
|
|
||||||
|
tester: function(){
|
||||||
|
this.LOG.info("tester function", "tester");
|
||||||
|
var fulfillmentPlanUtils = new FulfillmentPlanUtils();
|
||||||
|
fulfillmentPlanUtils.tester();
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'QueueUtils'
|
||||||
|
};
|
||||||
|
|
||||||
|
new ProcessorUtils("x_355681_fa").wrapPrototype(QueueUtils.prototype);
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
var TriggerUtils = Class.create();
|
||||||
|
TriggerUtils.prototype = {
|
||||||
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshConditionTable: function(){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
runTriggerScript: function(scriptGr, taskGr){
|
||||||
|
var answer = false;
|
||||||
|
|
||||||
|
var vars = {
|
||||||
|
'current' : taskGr || current
|
||||||
|
};
|
||||||
|
|
||||||
|
var evaluator = new GlideScopedEvaluator();
|
||||||
|
answer = evaluator.evaluateScript(scriptGr, 'condition_script', vars);
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
|
|
||||||
|
type: 'TriggerUtils'
|
||||||
|
};
|
||||||
|
|
||||||
|
new ProcessorUtils("x_355681_fa").wrapPrototype(TriggerUtils.prototype);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
function onClick(g_form) {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
(function(action, current) { action.setRedirectURL("/x_355681_fa_task_trigger.do?sysparm_query_override=condition_table="+current.getTableName());
|
||||||
|
})(action, current);
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
function faSettings(){
|
||||||
|
var answer = {
|
||||||
|
prepare: function(){
|
||||||
|
Formio.projectUrl = "https://dev63912.service-now.com"; //TODO
|
||||||
|
Formio.Templates.framework = "bootstrap3";
|
||||||
|
},
|
||||||
|
|
||||||
|
setupForm: function(elementID, schema, submission, submitEndPoint,resources){
|
||||||
|
Formio.createForm(document.getElementById(elementID), schema, setHooks()).then(function(form){
|
||||||
|
form.nosubmit = true;
|
||||||
|
if(submission){
|
||||||
|
submission._resources = resources;
|
||||||
|
form.submission = {
|
||||||
|
data: submission
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On submit function to save in the system instead of the API */
|
||||||
|
form.on('submit', function(submission){
|
||||||
|
delete submission.data.submit;
|
||||||
|
if(submitEndPoint.script_include && submitEndPoint.function){
|
||||||
|
var ga = new GlideAjax(submitEndPoint.script_include);
|
||||||
|
ga.addParam('sysparm_name', submitEndPoint.function);
|
||||||
|
ga.addParam('sysparm_property', "x_355681_fa.form.admin.settings");
|
||||||
|
ga.addParam('sysparm_value', JSON.stringify(submission.data, undefined, 2));
|
||||||
|
ga.getXMLAnswer(function(answer){
|
||||||
|
if(answer){
|
||||||
|
form.emit('submitDone', submission);
|
||||||
|
}else{
|
||||||
|
form.emit('submitError', answer);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Some internal functions that are not open to public */
|
||||||
|
function setHooks(){
|
||||||
|
return {
|
||||||
|
hooks: {
|
||||||
|
beforeSubmit: formBeforeSubmit
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function formBeforeSubmit(submission, next){
|
||||||
|
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
api.controller=function($timeout, faSettings) {
|
||||||
|
/* widget controller */
|
||||||
|
var c = this;
|
||||||
|
var schema, submission;
|
||||||
|
console.log("c", c)
|
||||||
|
if(c.data.schema) schema = JSON.parse(c.data.schema);
|
||||||
|
if(c.data.submission) submission = JSON.parse(c.data.submission);
|
||||||
|
|
||||||
|
var submitEndpoint = {
|
||||||
|
script_include: "x_355681_fa.CoreClientUtils",
|
||||||
|
function: "saveProperty",
|
||||||
|
keys: []
|
||||||
|
}
|
||||||
|
|
||||||
|
var resources = {
|
||||||
|
taskTables: c.data.taskTables,
|
||||||
|
scCatItemTables: c.data.scCatItemTables,
|
||||||
|
roles: c.data.roles
|
||||||
|
}
|
||||||
|
|
||||||
|
faSettings.prepare();
|
||||||
|
faSettings.setupForm('formio', schema, submission, submitEndpoint, resources);
|
||||||
|
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user