This function executes a resource include, but protects values specified by a dynamicdata table from being changed. The column names in the data table are used as the list of variables names that must be protected. These variables are protected by temporarily caching them, calling the include, and then resetting those variables back to the cached values. If a variable was null, it is set to blank.

If one of the column names in the table starts with a dollar symbol ($), then the string that follows is assumed to be the name of a result set. In that case, it is the pointer to the result set that is temporarily cached in memory and then replaced after the resource include has finished executing. If the result set did not exist at the time of caching, then any result set that exists with that key at the end are removed. If the result set is active at the time it has its pointer cached, new result sets of the same name can be created during the call of the include and the previously active result set will be recovered appropriately without disturbing the loop. The one side effect is that if a new result set is created that temporarily replaces the active result set, then the algorithm for variable substitution that retrieves values first from active result sets can find values for a variable from the cached active result set (assuming the variable is not found as a field in an active result set with higher precedence). The cached active result set maintains its place in the active result set stack,

Type and Usage


The following table lists parameters for the function.

Parameters Description
includeName The name of the resource include to execute.
dataTableName The name of the dynamicdata table to use for preserving local data and result sets..


A string representing the output of the executed resource include.


<@dynamicdata MyPreservedFields@>foo, bar, $baz<@end@>

<@dynamichtml my_include@>    <$foo = "tempValue1"$>    <$bar = "tempValue2"$><@end@>

<$foo = 5$><$ddIncludePreserveValues("my_include", "MyPreservedFields")$><$trace(foo, "#console")$>   [[% Outputs: 5 %]]