Mapping data from different context data variables into the same prop | Community
Skip to main content
Level 2
June 15, 2023
Solved

Mapping data from different context data variables into the same prop

  • June 15, 2023
  • 1 reply
  • 1541 views

Hi,

I am trying create a processing rule that sends the data from 5 different context data variables to the same prop, without them overwriting each other. Does anyone know if and how that can be done? Thankful for any tips!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jennifer_Dungan

Normally you would want to do a "Concatenation" rule, rather than a straight up overwrite...

 

I assume that you would have a specified format? 

 

Something like:

changeType_context_source_tabType_origin

or 

changeType|context|source|tabType|origin

 

Then there is the possibility of whether or not you have a placeholder like "na" when no value is available, or if the item is left out completely:

 

changeType_context_source_na_origin

or

changeType_context_source_origin

 

 

 

And those rules will need slightly different behaviour... but the basics would be:

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter _

     change_type(Context Data)

     context(Context Data)

     source(Context Data)

     tabtype(Context Data)

     origin(Context Data)

 

 

Or, if you need to build in the possibility of optional values. Believe it or not, having "na" placeholders is easier, here would be a way to do that:

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

     change_type(Context Data)

     (Condition) If change_type(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

     Custom Value na

     (Condition) If change_type(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    context(Context Data)

    (Condition) If context(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If context(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    source(Context Data)

    (Condition) If source(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If source(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    tabtype(Context Data)

    (Condition) If tabtype(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If tabtype(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    origin(Context Data)

    (Condition) If origin(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If origin(Context Data) is not set

 

 

 

Basically, for each item, you create a rule to use the context variable IF it exists, and to use "na" if it doesn't exist... then just keep concatenating values onto your prop...

 

If you don't have placeholders, that one can get tricky... only because of those set delimiters... you actually have to use different rules as you need 2 conditions... one to check if there is a value already in prop46 (to know whether or not to add an _ before adding the context variable), and one to know if you have a value in the context variable to add anything at all....

 

Unfortunately, at each Action level, you can only add one condition... if we could have multiple it would be similar to above... but with no placeholders, you can do a simple overwrite with change_type(Context Data)

 

Then you need to have another rule that checks if the next context variable exist (context(Context Data)), if it does, then you need two actions.. one that checks if Prop46 is set to know IF to concatenate the _ and then a simple concatenate for the context variable... (you can concatenate empty prop46 with the context... so only the _ action requires a condition:

 

Main Condition - IF context(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    (Condition) If Event Context (p46) (Prop46) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    context(Context Data)

 

 

Make rules for each context variable...

 

This will prevent you from ending up with your prop starting / ending with, or having multiple delimiters in a row

 

_value__value2_

 

 

 

But I suspect you want either placeholders, or those delimiters for easier classification rules... but it's good to show you that you can do that, if that is your final goal

1 reply

Jennifer_Dungan
Community Advisor and Adobe Champion
Jennifer_DunganCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
June 15, 2023

Normally you would want to do a "Concatenation" rule, rather than a straight up overwrite...

 

I assume that you would have a specified format? 

 

Something like:

changeType_context_source_tabType_origin

or 

changeType|context|source|tabType|origin

 

Then there is the possibility of whether or not you have a placeholder like "na" when no value is available, or if the item is left out completely:

 

changeType_context_source_na_origin

or

changeType_context_source_origin

 

 

 

And those rules will need slightly different behaviour... but the basics would be:

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter _

     change_type(Context Data)

     context(Context Data)

     source(Context Data)

     tabtype(Context Data)

     origin(Context Data)

 

 

Or, if you need to build in the possibility of optional values. Believe it or not, having "na" placeholders is easier, here would be a way to do that:

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

     change_type(Context Data)

     (Condition) If change_type(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

     Custom Value na

     (Condition) If change_type(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    context(Context Data)

    (Condition) If context(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If context(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    source(Context Data)

    (Condition) If source(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If source(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    tabtype(Context Data)

    (Condition) If tabtype(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If tabtype(Context Data) is not set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    origin(Context Data)

    (Condition) If origin(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    Custom Value na

    (Condition) If origin(Context Data) is not set

 

 

 

Basically, for each item, you create a rule to use the context variable IF it exists, and to use "na" if it doesn't exist... then just keep concatenating values onto your prop...

 

If you don't have placeholders, that one can get tricky... only because of those set delimiters... you actually have to use different rules as you need 2 conditions... one to check if there is a value already in prop46 (to know whether or not to add an _ before adding the context variable), and one to know if you have a value in the context variable to add anything at all....

 

Unfortunately, at each Action level, you can only add one condition... if we could have multiple it would be similar to above... but with no placeholders, you can do a simple overwrite with change_type(Context Data)

 

Then you need to have another rule that checks if the next context variable exist (context(Context Data)), if it does, then you need two actions.. one that checks if Prop46 is set to know IF to concatenate the _ and then a simple concatenate for the context variable... (you can concatenate empty prop46 with the context... so only the _ action requires a condition:

 

Main Condition - IF context(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    Custom Value _

    (Condition) If Event Context (p46) (Prop46) is set

 

Overwrite the value of Event Context (p46) (Prop46) with Concatenated Value Delimiter (leave blank)

    Event Context (p46) (Prop46)

    context(Context Data)

 

 

Make rules for each context variable...

 

This will prevent you from ending up with your prop starting / ending with, or having multiple delimiters in a row

 

_value__value2_

 

 

 

But I suspect you want either placeholders, or those delimiters for easier classification rules... but it's good to show you that you can do that, if that is your final goal

Olsson-2Author
Level 2
June 16, 2023

Hi

Thank you for the quick response, but as the context variables are not in the same server call, I would not like the values to be concatenated, but rather to be sent in separately. So the result I want is a mix of the data from each context variable in the same prop. The purpose is then to use use the prop to break down the different "Action Name" values connected to each context variable. Is that possible to achieve?

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 16, 2023

If there is no chance of those context variables being set at the same time, you probably could have created one general multi-use context variable...

 

But as it is, your existing rule is almost there... you just need to add conditions on each line...

 

At this moment, you have an overall rule that looks if ANY of those are set, which is good... but then when you set the values, there is an order, and your context variable "origin" is last.... meaning when it's not set, it will be "" and this is overriding the previous set value.

 

But if you do this:

 

Overwrite the value of Event Context (p46) (Prop46) with

change_type(Context Data)

    (Condition) If change_type(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with

context(Context Data)

    (Condition) If context(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with

source(Context Data)

    (Condition) If source(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with

tabtype(Context Data)

    (Condition) If tabtype(Context Data) is set

 

Overwrite the value of Event Context (p46) (Prop46) with

origin(Context Data)

    (Condition) If origin(Context Data) is set

 

 

 

This adds just that extra logic to set the value of prop46 with the specific value that is set, and not use the ones not in use.