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
  • 1557 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 19, 2023

Thank you so much for that answer, I have now changed the rule accordingly and it seems to be working. I just want to double check that I understood correctly (see attached file). And a follow up question: What would be the outcome if the context variables stated in the the rule occur in the same server call (which should normally not be the case)?

And yes, we will be looking at changing the context variables to be the same in all places using the rule, this is just a tactical solution.


Looks good to me 🙂

 

What would be the outcome if the context variables stated in the the rule occur in the same server call (which should normally not be the case)?

 

Basically it will be similar to your previous rule... the last action in the list will take priority.

 

So in your initial version, the one without the conditions on each action, let's say you had "change_type" being sent, all the actions that followed it overwrote the prop46 with nothing... 

 

However, in the new rules, let's say you have context and origin set in the same call, because origin comes last, it will be the one to process last and take priority of the value.