Event Forwarding - Error "Referenced Data Element are not added to the build: arc.event.xdm" | Community
Skip to main content
Level 2
December 2, 2024
Solved

Event Forwarding - Error "Referenced Data Element are not added to the build: arc.event.xdm"

  • December 2, 2024
  • 2 replies
  • 1131 views

Hi there,

 

I am trying to use Event Forwarding to send data to other systems dynamically. The scenario is multi-brand, so I have different XDM schema fields referring to the same concept (e.g.: identities.brand1.ecid, identities.brand2.ecid). I want Event Forwarding to adapt the request depending on the origin (brand) of the data, so I have decided to create a dynamic Data Element via custom JS code:

 

 

let ecid; var xdmObject = getDataElementValue('arc.event.xdm'); if(xdmObject){ if (url.includes("brand1.com")) { ecid = xdmObject._sandboxname.identities.brand1.profile.ecid.id; } else if (url.includes("brand2.com")) { ecid = xdmObject._sandboxname.identities.brand2.profile.ecid.id; } else { // Handle cases where the URL does not match any known hosts console.warn('Unknown host in URL:', url); ecid = ""; } } return ecid

 

 

Nevertheless, when I try to Build the code I get the next error:

 

There was an error minifying your custom code.
Referenced DataElements are not added to the build: arc.event.xdm
 
Where am I doing wrong? I was assuming "arc.event.xdm" could be directly accessed from Event Forwarding custom code. Could you please provide some guidance on this?
 
Thanks in advance
Best answer by bjoern__koth

Hi @jlasso71 

arc.event.xdm is actually a path to the request payload. Have you created a data element with exactly this name?

If so, make sure to include it in your Library.

 

If you are just using custom code, you won't need to pull this data element in, since you can just directly reference it from your custom code.

 

arc.event.xdm.path.to.data

 

Just beware that you must make sure your code checks for anything being unset in your object structure.

Luckily, nowadays, this is pretty easy in Javascript and you can use Optional Chaining to access anything at any depth in your object structure, by using "?." instead of "." to access the next level. As soon as any part is not set, it will stop executing and not fail.

 

// the old world if (arc && arc.event && arc.event.xdm && arc.event.xdm._sandboxname && arc.event.xdm._sandboxname.identities && arc.event.xdm._sandboxname.identities.brand1 && arc.event.xdm._sandboxname.identities.brand1.profile && arc.event.xdm._sandboxname.identities.brand1.profile.ecid && arc.event.xdm._sandboxname.identities.brand1.profile.ecid.id) { // boy this is long! } // the new world if (arc?.event?.xdm?._sandboxname?.identities?.brand1?.profile?.ecid?.id) { // much better }

 

In other words, if you were accessing arc.event.xdm.hello.world through code, and any part of this path is not set, you would get an error.

 

So, if you know already that you have a specific number of brands, maybe you are better off with creating dedicated data elements

since access to this Path is implicitly failsafe.

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
December 3, 2024

Hello @jlasso71  You can create rules.

 

First store the the value of URL in a data element like this:

 

 

Then create a URL to check the value and fire the custom code

 

Manoj  | https://themartech.pro
jlasso71Author
Level 2
December 3, 2024

Hi Manoj,

 

Thanks for your prompt response. Your solution makes sense but it requires one rule per brand (I have more than 20 brands in some cases). Also, I would need a Data Element per each XDM path, which is something I would definitely like to avoid.

 

Have you tried to access "arc.event.xdm" directly from Event Forwarding custom code? 

 

Best regards,

bjoern__koth
Community Advisor and Adobe Champion
bjoern__kothCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
December 3, 2024

Hi @jlasso71 

arc.event.xdm is actually a path to the request payload. Have you created a data element with exactly this name?

If so, make sure to include it in your Library.

 

If you are just using custom code, you won't need to pull this data element in, since you can just directly reference it from your custom code.

 

arc.event.xdm.path.to.data

 

Just beware that you must make sure your code checks for anything being unset in your object structure.

Luckily, nowadays, this is pretty easy in Javascript and you can use Optional Chaining to access anything at any depth in your object structure, by using "?." instead of "." to access the next level. As soon as any part is not set, it will stop executing and not fail.

 

// the old world if (arc && arc.event && arc.event.xdm && arc.event.xdm._sandboxname && arc.event.xdm._sandboxname.identities && arc.event.xdm._sandboxname.identities.brand1 && arc.event.xdm._sandboxname.identities.brand1.profile && arc.event.xdm._sandboxname.identities.brand1.profile.ecid && arc.event.xdm._sandboxname.identities.brand1.profile.ecid.id) { // boy this is long! } // the new world if (arc?.event?.xdm?._sandboxname?.identities?.brand1?.profile?.ecid?.id) { // much better }

 

In other words, if you were accessing arc.event.xdm.hello.world through code, and any part of this path is not set, you would get an error.

 

So, if you know already that you have a specific number of brands, maybe you are better off with creating dedicated data elements

since access to this Path is implicitly failsafe.

Cheers from Switzerland!
jlasso71Author
Level 2
December 5, 2024

Hi @bjoern__koth ,

 

Thanks for your response, your solution using Optional Chaining is really powerful. The problem we have is that when accessing arc.event.xdm.hello.world through code we are not even able to publish the changes:

 

There was an error minifying your custom code.
Referenced DataElements are not added to the build: arc.event.xdm

 

Regarding using failsafe data elements, we do not want to create dedicated data elements per brand due to operative costs (20-30 brands * 5-10 paths = 100-300 data elements).

 

Best regards,

Level 2
December 5, 2024

Can you post your code or screenshot of it? Should be an easy explanation for the error.

if you don't want to share the code publicly, you can also send me a DM