snow-flow 10.0.1-dev.413 → 10.0.1-dev.415
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -124,11 +124,11 @@ async function createFlowViaScheduledJob(
|
|
|
124
124
|
" } catch(t1e) { r.steps.tier1 = { success: false, error: t1e.getMessage ? t1e.getMessage() : t1e + '' }; }",
|
|
125
125
|
"",
|
|
126
126
|
// ── TIER 2: GlideRecord ──
|
|
127
|
-
// Reference flow analysis
|
|
128
|
-
// -
|
|
129
|
-
// -
|
|
130
|
-
// - latest_version = null (normal
|
|
131
|
-
//
|
|
127
|
+
// Reference flow analysis:
|
|
128
|
+
// - latest_snapshot points to sys_hub_flow_snapshot (NOT version, NOT JSON)
|
|
129
|
+
// - flow_definition on flow record = null
|
|
130
|
+
// - latest_version = null (normal)
|
|
131
|
+
// Pipeline: flow → version → snapshot → set latest_snapshot on flow
|
|
132
132
|
" if (!flowSysId) {",
|
|
133
133
|
" try {",
|
|
134
134
|
" var f = new GlideRecord('sys_hub_flow');",
|
|
@@ -138,11 +138,10 @@ async function createFlowViaScheduledJob(
|
|
|
138
138
|
" f.setValue('run_as', runAs); f.setValue('active', false);",
|
|
139
139
|
" f.setValue('status', 'draft'); f.setValue('validated', true);",
|
|
140
140
|
" f.setValue('type', isSubflow ? 'subflow' : 'flow');",
|
|
141
|
-
// Do NOT set flow_definition (null on working flows)
|
|
142
|
-
// Do NOT set latest_snapshot yet (set after version insert — it's a sys_id ref)
|
|
143
141
|
" flowSysId = f.insert();",
|
|
144
142
|
" r.steps.flow_insert = { success: !!flowSysId, sys_id: flowSysId + '' };",
|
|
145
143
|
" if (flowSysId) {",
|
|
144
|
+
// Version record
|
|
146
145
|
" var v = new GlideRecord('sys_hub_flow_version');",
|
|
147
146
|
" v.initialize();",
|
|
148
147
|
" v.setValue('flow', flowSysId); v.setValue('name', '1.0');",
|
|
@@ -153,16 +152,41 @@ async function createFlowViaScheduledJob(
|
|
|
153
152
|
" verSysId = v.insert();",
|
|
154
153
|
" r.steps.version_insert = { success: !!verSysId, sys_id: verSysId + '' };",
|
|
155
154
|
"",
|
|
156
|
-
//
|
|
157
|
-
|
|
155
|
+
// Create snapshot in sys_hub_flow_snapshot (this is what latest_snapshot points to!)
|
|
156
|
+
// Reference snapshot fields: parent_flow, master, internal_name, type, run_as,
|
|
157
|
+
// access, active, status, name, sc_callable, callable_by_client_api
|
|
158
|
+
" var snapId = null;",
|
|
159
|
+
" try {",
|
|
160
|
+
" var snap = new GlideRecord('sys_hub_flow_snapshot');",
|
|
161
|
+
" if (snap.isValid()) {",
|
|
162
|
+
" snap.initialize();",
|
|
163
|
+
" snap.setValue('name', flowName);",
|
|
164
|
+
" snap.setValue('internal_name', intName);",
|
|
165
|
+
" snap.setValue('parent_flow', flowSysId);",
|
|
166
|
+
" snap.setValue('type', isSubflow ? 'subflow' : 'flow');",
|
|
167
|
+
" snap.setValue('run_as', runAs);",
|
|
168
|
+
" snap.setValue('access', 'public');",
|
|
169
|
+
" snap.setValue('active', true);",
|
|
170
|
+
" snap.setValue('master', true);",
|
|
171
|
+
" snap.setValue('status', 'draft');",
|
|
172
|
+
" try { snap.setValue('sc_callable', false); } catch(e) {}",
|
|
173
|
+
" try { snap.setValue('callable_by_client_api', false); } catch(e) {}",
|
|
174
|
+
" snapId = snap.insert();",
|
|
175
|
+
" r.steps.snapshot_insert = { success: !!snapId, sys_id: snapId + '' };",
|
|
176
|
+
" } else { r.steps.snapshot_insert = { success: false, error: 'table not valid' }; }",
|
|
177
|
+
" } catch(snapE) { r.steps.snapshot_insert = { success: false, error: snapE.getMessage ? snapE.getMessage() : snapE + '' }; }",
|
|
178
|
+
"",
|
|
179
|
+
// Set latest_snapshot on flow to point to the snapshot record
|
|
180
|
+
" var snapshotRef = snapId || verSysId;",
|
|
181
|
+
" if (snapshotRef) {",
|
|
158
182
|
" try {",
|
|
159
183
|
" var flowUpd = new GlideRecord('sys_hub_flow');",
|
|
160
184
|
" if (flowUpd.get(flowSysId)) {",
|
|
161
|
-
" flowUpd.setValue('latest_snapshot',
|
|
185
|
+
" flowUpd.setValue('latest_snapshot', snapshotRef);",
|
|
162
186
|
" flowUpd.update();",
|
|
163
|
-
" r.steps.latest_snapshot_set =
|
|
187
|
+
" r.steps.latest_snapshot_set = { value: snapshotRef + '', source: snapId ? 'snapshot' : 'version' };",
|
|
164
188
|
" }",
|
|
165
|
-
" } catch(lsE) { r.steps.latest_snapshot_set =
|
|
189
|
+
" } catch(lsE) { r.steps.latest_snapshot_set = { error: lsE.getMessage ? lsE.getMessage() : lsE + '' }; }",
|
|
166
190
|
" }",
|
|
167
191
|
" r.tier_used = 'gliderecord_scheduled'; r.success = true;",
|
|
168
192
|
" }",
|
|
@@ -289,37 +313,27 @@ async function createFlowViaScheduledJob(
|
|
|
289
313
|
" latest_snapshot_value: refLs,",
|
|
290
314
|
" latest_version: refGr.getValue('latest_version') + ''",
|
|
291
315
|
" };",
|
|
292
|
-
//
|
|
316
|
+
// Read the reference snapshot record fields (sys_hub_flow_snapshot)
|
|
293
317
|
" if (refLs !== 'null' && refLs.length === 32) {",
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
297
|
-
"
|
|
298
|
-
|
|
299
|
-
"
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
"
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
|
|
306
|
-
"
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
" if (metaGr.get(refLs)) {",
|
|
310
|
-
" r.steps.reference_flow.snapshot_found_in_table = metaGr.getValue('sys_class_name') + '';",
|
|
318
|
+
" try {",
|
|
319
|
+
" var refSnap = new GlideRecord('sys_hub_flow_snapshot');",
|
|
320
|
+
" if (refSnap.get(refLs)) {",
|
|
321
|
+
" r.steps.reference_flow.snapshot_table = 'sys_hub_flow_snapshot';",
|
|
322
|
+
// Read all non-null fields to learn the schema
|
|
323
|
+
" var snapFields = {};",
|
|
324
|
+
" var snapEl = refSnap.getFields();",
|
|
325
|
+
" for (var si = 0; si < snapEl.size(); si++) {",
|
|
326
|
+
" var sField = snapEl.get(si);",
|
|
327
|
+
" var sName = sField.getName() + '';",
|
|
328
|
+
" var sVal = refSnap.getValue(sName);",
|
|
329
|
+
" if (sVal && sName.indexOf('sys_') !== 0) {",
|
|
330
|
+
" var sStr = sVal + '';",
|
|
331
|
+
" snapFields[sName] = sStr.length > 100 ? sStr.substring(0, 100) + '...(len:' + sStr.length + ')' : sStr;",
|
|
332
|
+
" }",
|
|
311
333
|
" }",
|
|
312
|
-
"
|
|
313
|
-
"
|
|
314
|
-
"
|
|
315
|
-
// Get field descriptor for latest_snapshot to see its reference table
|
|
316
|
-
" var fd = refGr.getElement('latest_snapshot');",
|
|
317
|
-
" if (fd) {",
|
|
318
|
-
" var ed = fd.getED();",
|
|
319
|
-
" if (ed) {",
|
|
320
|
-
" r.steps.reference_flow.snapshot_field_type = ed.getInternalType() + '';",
|
|
321
|
-
" r.steps.reference_flow.snapshot_field_reference = ed.getReference() + '';",
|
|
322
|
-
" }",
|
|
334
|
+
" r.steps.reference_flow.snapshot_fields = snapFields;",
|
|
335
|
+
" }",
|
|
336
|
+
" } catch(snapRefE) { r.steps.reference_flow.snapshot_error = snapRefE + ''; }",
|
|
323
337
|
" }",
|
|
324
338
|
// Count trigger/action instances for reference flow
|
|
325
339
|
" var refTrig = new GlideAggregate('sys_hub_trigger_instance');",
|