Variables in includes

You can use variables to pass information from a parent property to an include. Each include has its own local variables, but can also access variables of the parent properties.

Using variables within an Include will look like this in the PM UI:

When you create a local variable in an include, the name of the include will start with an automatically generated prefix, PMINC, followed by the IncludeId, which makes the local variable names unique to avoid namespace collisions.

Note: TheVariable names can only be up to 32 characters, and since the local variable prefix takes up 12 characters, your actual local variable name (e.g. “FOO”) can be 20 characters max.

Property Manager UI

In the PM UI, when you type {{ in a field that supports variables you can select your local variables from a drop down list.

Note: You have to save the Include before you can add local variables.

PAPI

In the PAPI json, you declare local variables like this (note the 1234 prefix in the example is the same as the includeId!) :

   "variables": [
       {
           "name": "PMINC1234_FOO",
           "value": "Value of Local FOO",
           "description": "test",
           "hidden": false,
           "sensitive": false
       }
   ],

And then reference them in behavior fields that support variables like this (also showing how to reference global/parent and built-in variables):

   "behaviors": [
       {
           "name": "constructResponse",
           "options": {
               "enabled": true,
               "responseCode": 200,
               "body": "somestring\nLocal FOO={{user.PMINC1234_FOO}}\nParent FOO={{parent.PMUSER_FOO}}",
               "forceEviction": false,
               "ignorePurge": true
           }
       }
   ],

Note: You have to create the Include before you get the includeId prefix for the local variable names!

Global/parent variables
Parent variables can be referenced from within an Include by prepending “{{parent.”. You have to just type it in, as the PM UI will not show the list of parent variables in a drop down list.

Note: When referencing a parent variable that doesn’t exist, you will get a blank value at request time.

When setting the value of a parent variable using the Set Variable behavior, you will see a new option to manually type in the variable name. Use this option to set a parent variable. Just type in “parent.PMUSER_VARIABLENAME”.

Note: If you’re setting the value of a parent variable that doesn’t exist, you will actually create it at runtime and it will technically work, however the parent config will not see it.

Built-In/System variables
Builtin variables work exactly like they do in parent properties. They are essentially global variables that are populated automatically by the Akamai edge server.

Example
Let’s look at a typical scenario.

1 - Parent property sets global variable FOO

2 - Include sets local variable FOO

3 - Include combines global variable FOO and local variable FOO together

The resulting redirect path will be /123456. “/” being a static value, “123” being the value of the local variable FOO (technically PMINC123456_FOO), and “456” being the value of the parent variable FOO (technically PMUSER_FOO).

Here is the PAPI json for this redirect behavior:

{
"includeVersion": 2,
"network": "STAGING",
"name": "redirect",
"useFastFallback": false,
"options": {
"mobileDefaultChoice": "DEFAULT",
"destinationProtocol": "SAME_AS_REQUEST",
"destinationHostname": "SAME_AS_REQUEST",
"destinationPath": "OTHER",
"queryString": "APPEND",
"responseCode": 302,
"destinationPathOther": "/{{user.PMINC123456_FOO}}{{parent.PMUSER_FOO}}"
}
}

4 - Include updates global variable FOO

<TBD - Waiting for UI to catch up for screenshot>
Variables and Custom Behaviors
Property Manager Custom Behaviors can only reference parent/global variables.

You can use Custom Behaviors in your Include, and the Custom Behavior can leverage variables, but since local variables use a unique prefix (PMINC123456_) you cannot reference them reliably in the Custom Behavior.

Note: Internal Akamai Staff - Do not add unsupported behavior XML into the Custom Behaviors as this may lead to unexpected results. See limitations section above for features that are not supposed to go in the Includes during the beta.