Expand my Community achievements bar.

SOLVED

Mapping data from different context data variables into the same prop

Avatar

Level 2

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!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 2

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?

Avatar

Community Advisor

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.

Avatar

Level 2

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.

Avatar

Community Advisor

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.

Avatar

Level 2

Ok, I see, thanks a lot for your help in explaining this!