This is supported from 10.1 onwards.
This document discusses the JSON representation used to describe a layerSource object.
There are two types of layerSource objects:
dataSource
Dynamic map layer refers to a layer in the current map service. If supported, use gdbVersion to specify an alternate geodatabase version.
Note: type and mapLayerId are required.
{
"type": "mapLayer", //required
"mapLayerId": <layerId>, //required
"gdbVersion": "<version name>"
}
{
"type": "mapLayer",
"mapLayerId": 3,
"gdbVersion": "SDE.dynamicLayers"
}
Dynamic data layer is an on-the-fly layer created off of data from a registered workspace.
Depending on the type of dataSource these layers are classified as:
fields to control field visibility. If this value is null, then all the fields would be visible on the dynamicLayer.
type and dataSource are required elements.
{
"type": "dataLayer", //required
"dataSource": <dataSource>, //required
"fields":
[
{"name":"<fieldName1>","alias":"<fieldAlias1>"},
{"name":"<fieldName2>","alias":"<fieldAlias2>"}
]
}
{
"type": "dataLayer",
"dataSource":
{
"type": "table",
"workspaceId": "MAP",
"dataSourceName": "SDE.Counties",
"gdbVersion": "SDE.dynamicLayers"
},
"fields": [
{"name":"name","alias":"County Name"},
{"name":"fips","alias":"County FIPS"}
]
}