snow-flow 10.0.1-dev.408 → 10.0.1-dev.410
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
|
@@ -123,9 +123,10 @@ async function createFlowViaScheduledJob(
|
|
|
123
123
|
" }",
|
|
124
124
|
" } catch(t1e) { r.steps.tier1 = { success: false, error: t1e.getMessage ? t1e.getMessage() : t1e + '' }; }",
|
|
125
125
|
"",
|
|
126
|
-
// ── TIER 2: GlideRecord
|
|
127
|
-
//
|
|
128
|
-
//
|
|
126
|
+
// ── TIER 2: GlideRecord ──
|
|
127
|
+
// Set flow_definition + latest_snapshot on flow record.
|
|
128
|
+
// Set flow_definition on version record.
|
|
129
|
+
// Force-set latest_version with setWorkflow(false) to bypass BRs.
|
|
129
130
|
" if (!flowSysId) {",
|
|
130
131
|
" try {",
|
|
131
132
|
" var f = new GlideRecord('sys_hub_flow');",
|
|
@@ -135,30 +136,39 @@ async function createFlowViaScheduledJob(
|
|
|
135
136
|
" f.setValue('run_as', runAs); f.setValue('active', false);",
|
|
136
137
|
" f.setValue('status', 'draft'); f.setValue('validated', true);",
|
|
137
138
|
" f.setValue('type', isSubflow ? 'subflow' : 'flow');",
|
|
139
|
+
" if (flowDefStr) { f.setValue('flow_definition', flowDefStr); f.setValue('latest_snapshot', flowDefStr); }",
|
|
138
140
|
" flowSysId = f.insert();",
|
|
139
|
-
" r.steps.flow_insert = { success: !!flowSysId, sys_id: flowSysId + '' };",
|
|
141
|
+
" r.steps.flow_insert = { success: !!flowSysId, sys_id: flowSysId + '', flow_def_set: !!flowDefStr };",
|
|
140
142
|
" if (flowSysId) {",
|
|
141
|
-
// Step 1: INSERT version as minimal draft
|
|
142
143
|
" var v = new GlideRecord('sys_hub_flow_version');",
|
|
143
144
|
" v.initialize();",
|
|
144
145
|
" v.setValue('flow', flowSysId); v.setValue('name', '1.0');",
|
|
145
146
|
" v.setValue('version', '1.0'); v.setValue('state', 'draft');",
|
|
146
|
-
" v.setValue('active',
|
|
147
|
-
" v.setValue('is_current',
|
|
147
|
+
" v.setValue('active', true); v.setValue('compile_state', 'draft');",
|
|
148
|
+
" v.setValue('is_current', true);",
|
|
149
|
+
" v.setValue('internal_name', intName + '_v1_0');",
|
|
150
|
+
" if (flowDefStr) { v.setValue('flow_definition', flowDefStr); }",
|
|
148
151
|
" verSysId = v.insert();",
|
|
149
|
-
" r.steps.version_insert = { success: !!verSysId, sys_id: verSysId + '' };",
|
|
150
|
-
|
|
152
|
+
" r.steps.version_insert = { success: !!verSysId, sys_id: verSysId + '', has_flow_def: !!flowDefStr };",
|
|
153
|
+
"",
|
|
154
|
+
// Force-set latest_version — bypass BRs with setWorkflow(false)
|
|
151
155
|
" if (verSysId) {",
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
|
|
156
|
+
" try {",
|
|
157
|
+
" var flowUpd = new GlideRecord('sys_hub_flow');",
|
|
158
|
+
" flowUpd.setWorkflow(false);",
|
|
159
|
+
" flowUpd.autoSysFields(false);",
|
|
160
|
+
" if (flowUpd.get(flowSysId)) {",
|
|
161
|
+
" flowUpd.setValue('latest_version', verSysId);",
|
|
162
|
+
" flowUpd.update();",
|
|
163
|
+
" r.steps.latest_version_force = 'attempted';",
|
|
164
|
+
" }",
|
|
165
|
+
" } catch(lvE) { r.steps.latest_version_force = 'error:' + (lvE.getMessage ? lvE.getMessage() : lvE + ''); }",
|
|
166
|
+
// Verify latest_version was set
|
|
159
167
|
" var lvCheck = new GlideRecord('sys_hub_flow');",
|
|
160
168
|
" if (lvCheck.get(flowSysId)) {",
|
|
161
|
-
"
|
|
169
|
+
" var lvVal = lvCheck.getValue('latest_version');",
|
|
170
|
+
" r.steps.latest_version_after_force = lvVal + '';",
|
|
171
|
+
" r.steps.latest_version_success = (lvVal === verSysId + '');",
|
|
162
172
|
" }",
|
|
163
173
|
" }",
|
|
164
174
|
" r.tier_used = 'gliderecord_scheduled'; r.success = true;",
|
|
@@ -1624,11 +1634,11 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
|
|
|
1624
1634
|
|
|
1625
1635
|
}
|
|
1626
1636
|
|
|
1627
|
-
// ── Register flow with Flow Designer engine
|
|
1628
|
-
//
|
|
1629
|
-
//
|
|
1630
|
-
//
|
|
1631
|
-
if (flowSysId
|
|
1637
|
+
// ── Register flow with Flow Designer engine ──
|
|
1638
|
+
// Call the REST API (publish/activate/checkout+checkin/snapshot) to
|
|
1639
|
+
// trigger engine compilation and set latest_version (computed field
|
|
1640
|
+
// that cannot be set via GlideRecord or Table API PATCH).
|
|
1641
|
+
if (flowSysId) {
|
|
1632
1642
|
var engineResult = await registerFlowWithEngine(client, flowSysId, shouldActivate);
|
|
1633
1643
|
diagnostics.engine_registration = {
|
|
1634
1644
|
success: engineResult.success,
|