Skip to content

Commit

Permalink
#844: automatically update name of activities during automation retrieve
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jun 1, 2023
1 parent 06d44d3 commit 392f744
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/metadataTypes/Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,39 @@ class Automation extends MetadataType {
// (config in Automation ) or unconfigured so no further action to be taken
if (
activity.activityObjectId === '00000000-0000-0000-0000-000000000000' ||
activity.activityObjectId == null ||
!this.definition.dependencies.includes(activity.r__type)
activity.activityObjectId == null
) {
Util.logger.debug(
` - skip parsing of activity due to missing activityObjectId: ${JSON.stringify(
activity
)}`
);
// empty if block
} else if (!this.definition.dependencies.includes(activity.r__type)) {
Util.logger.debug(
` - skip parsing because the type is not set up as a dependecy for ${this.definition.type}`
);
}
// / if managed by cache we can update references to support deployment
else if (
Definitions[activity.r__type]?.['idField'] &&
cache.getCache(this.buObject.mid)[activity.r__type]
) {
try {
activity.activityObjectId = cache.searchForField(
// this will override the name returned by the API in case this activity's name was changed since the automation was last updated, keeping things nicely in sync for mcdev
const name = cache.searchForField(
activity.r__type,
activity.activityObjectId,
Definitions[activity.r__type].idField,
Definitions[activity.r__type].nameField
);
if (name !== activity.name) {
Util.logger.debug(
` - updated name of step ${stepNumber}.${activity.displayOrder}` +
` of Automation '${metadata.name}' from ${activity.name} to ${name}`
);
activity.name = name;
}
} catch (ex) {
// getFromCache throws error where the dependent metadata is not found
Util.logger.warn(
Expand Down

0 comments on commit 392f744

Please sign in to comment.