@plusscommunities/pluss-maintenance-aws 2.1.20-auth.0 → 2.1.21

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.
@@ -130,10 +130,27 @@ class ArchibusStrategy extends IntegrationStrategy {
130
130
  TrackedData: {},
131
131
  });
132
132
 
133
- // Save the Archibus ID as the job number
133
+ // Save the Archibus ID as the job number and add history entry
134
+ const updatedJob = await getRef(
135
+ values.tableNameMaintenance,
136
+ "id",
137
+ request.id
138
+ );
139
+ if (!updatedJob.history) updatedJob.history = [];
140
+ updatedJob.history.push({
141
+ timestamp: moment.utc().valueOf(),
142
+ action: "ExternalIDSet",
143
+ externalId: response.data.wrId,
144
+ user: {
145
+ displayName: "Archibus Integration",
146
+ id: "system",
147
+ },
148
+ });
149
+
134
150
  await editRef(values.tableNameMaintenance, "id", request.id, {
135
151
  jobNo: response.data.wrId,
136
152
  jobId: response.data.wrId + "",
153
+ history: updatedJob.history,
137
154
  });
138
155
 
139
156
  // add images
@@ -148,6 +165,30 @@ class ArchibusStrategy extends IntegrationStrategy {
148
165
  return true;
149
166
  } catch (e) {
150
167
  log("Archibus:CreateRequest", "Error", e, logId);
168
+
169
+ // Add history entry for failed integration
170
+ try {
171
+ const failedJob = await getRef(
172
+ values.tableNameMaintenance,
173
+ "id",
174
+ request.id
175
+ );
176
+ if (!failedJob.history) failedJob.history = [];
177
+ failedJob.history.push({
178
+ timestamp: moment.utc().valueOf(),
179
+ action: "ExternalIDSetFailed",
180
+ user: {
181
+ displayName: "Archibus Integration",
182
+ id: "system",
183
+ },
184
+ });
185
+
186
+ await editRef(values.tableNameMaintenance, "id", request.id, {
187
+ history: failedJob.history,
188
+ });
189
+ } catch (historyError) {
190
+ log("Archibus:CreateRequest", "HistoryError", historyError, logId);
191
+ }
151
192
  }
152
193
  return false;
153
194
  };