Skip to content

Conversation

@yuliialikhyt
Copy link
Collaborator

@yuliialikhyt yuliialikhyt commented Nov 13, 2025

PR details

What changes did you make? (Give an overview)

Before
image

After
image

Added some changes to have the Data Extension field name resolved and add the Data Extension key to the journey instead of ObjectID.

Further details (optional)

...

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • test scripts updated
  • Wiki updated (if applicable)

@github-actions github-actions bot added the enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" label Nov 13, 2025
@github-actions
Copy link

github-actions bot commented Nov 13, 2025

Coverage Report

Commit:14d2477
Base: develop@36e9bb6

Type Base This PR
Total Statements Coverage  70.66%  70.72%  (+0.06%)
Total Branches Coverage  70.69%  70.7%  (+0.01%)
Total Functions Coverage  83.44%  83.46%  (+0.02%)
Total Lines Coverage  70.66%  70.72%  (+0.06%)
Details (changed files):
File Statements Branches Functions Lines
lib/metadataTypes/DataExtensionField.js  83%  69.64%  90.9%  83%
lib/metadataTypes/Journey.js  68.84%  67.29%  96%  68.84%

@yuliialikhyt yuliialikhyt marked this pull request as ready for review November 13, 2025 22:28
@yuliialikhyt yuliialikhyt self-assigned this Nov 14, 2025
const activityArguments = activity.arguments;
for (
let i = 0;
i < activityArguments.activityData.updateContactFields.length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are assuming activityData and updateContactFields both exist here. Better to use ?. notation to make sure you dont trigger a js error

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

) {
const contactField = activityArguments.activityData.updateContactFields[i];
try {
activityArguments.activityData.updateContactFields[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use contactField var instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@JoernBerkefeld JoernBerkefeld added the c/journey COMPONENT label Nov 17, 2025
@JoernBerkefeld JoernBerkefeld linked an issue Nov 17, 2025 that may be closed by this pull request
1 task
@JoernBerkefeld JoernBerkefeld force-pushed the feature/2252-resolve-update-contact-data-in-Journeys branch from 8ab518e to 4957506 Compare November 17, 2025 17:15
Comment on lines 1263 to 1268
Util.logger.warn(' - Caching dependent Metadata: dataExtensionField');
DataExtensionField.buObject = this.buObject;
DataExtensionField.client = this.client;
DataExtensionField.properties = this.properties;
const dataExtensionFieldCache =
await DataExtensionField.retrieveForCache();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only re-cache if dataExtensionFields were not already cached please. where you placed it, this caching gets executed once for every journey in your retrieve

You can find an example of how i did that in Journey.deploy and Journey._postRetrieveTasksBulk:

image image

I would recommend putting YOUR caching also into those 2 methods in a similar fashion (quick loop throuh journeys and the activities to check if the activity is even in the retrieve/deploy payload

Copy link
Contributor

@JoernBerkefeld JoernBerkefeld Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just realized, there might be a slightly better option here:
u can use something like in DataExtension._retrieveFieldsForSingleDe() - that way it works nicely even on BUs with a extremely large amount of DEs / fields.

that said, this will mean quite a bit of extra work

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a function in the DataExtensionField like the one in the DataExtension retrieveFieldsForSingleDe. Let me know if that is ok 🙂

dataExtensionFieldCache.metadata
);
try {
contactField.field = cache.searchForField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i get why you wanted to stick with "field" but the standard here would be r__dataExtensionField_name

try {
contactField.field = cache.searchForField(
'dataExtensionField',
`[${contactField.r__dataExtension_key}].[${contactField.field}]`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`[${contactField.r__dataExtension_key}].[${contactField.field}]`,
`[${contactField.r__dataExtension_key}].[${contactField.r__dataExtensionField_name}]`,

yuliialikhyt and others added 5 commits November 22, 2025 16:28
@JoernBerkefeld JoernBerkefeld added this to the 8.3.0 milestone Nov 24, 2025
@JoernBerkefeld JoernBerkefeld changed the title feature/2252 resolve update contact data in journeys feature/2252 resolve Update Contact Data activities in Journeys Nov 27, 2025
const fields = await DataExtensionField.retrieveFieldsForSingleDe(
contactField.r__dataExtension_key
);
cache.setMetadata('dataExtensionField', fields);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wont work because now your cache for dataExtensionField is existing - but you only inserted fields for a single DE. Therefore, if you run this code for 2 updatecontactdata activities with a different dataExtension then the second one will not recache fields and hence fail to find any.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what could work is if you were to reset the dataExtensionField cache after running searchForField again - but only if you didnt find a dataExtensionField cache in the first place? bit hacky but should be most efficient that way.

let tempCachedFields = false;
if (!cache.getCache().dataExtensionField) {
    tempCachedFields = true;
    ...
}
...  cache.searchForField(..);
if(tempCachedFields) {
    cache.clearCache(this.buObject.mid, 'dataExtensionField');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, makes sense. I made the changes as suggested, in preDeploy and postRetrieve. Since the function retrieves all fields per DE, and one Update Contact activity is related to one DE only, cache is cleared once per UPDATECONTACTDATA activity. It will not re-cache once for every field, but once per every data extension / Update Contact activity.

Comment on lines 1264 to 1278
if (!cache.getCache().dataExtensionField) {
DataExtensionField.buObject = this.buObject;
DataExtensionField.client = this.client;
DataExtensionField.properties = this.properties;
const fields = await DataExtensionField.retrieveFieldsForSingleDe(
contactField.r__dataExtension_key
);
cache.setMetadata('dataExtensionField', fields);
}
contactField.r__dataExtensionField_name = cache.searchForField(
'dataExtensionField',
contactField.field,
'ObjectID',
'Name'
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment on resetting the cache in _preDeployTasks_activities and solve similarly here

Comment on lines 50 to 54
const cachedDEs = cache.getCache().dataExtension;
if (cachedDEs) {
await DataExtension.attachFields(cachedDEs);
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert as you are not using this change. i believe whenever we want to cache fields, we ended up looking at them through dataExtensions alone and hence had the above logic in place


// Assign definition to static attributes
import MetadataTypeDefinitions from '../MetadataTypeDefinitions.js';
import cache from '../util/cache.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please restore in favor of old version of retrieveForCache()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted retrieveForCache() and brought back the imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c/journey COMPONENT enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] resolve Update Contact Data activities in Journeys

3 participants