Update an attribute
PATCH {{baseUrl}}/api/model/attributes/:attributeId?showExpressionAs=tree&removeInvalidFields=true
Updates a specific attribute in the changeset.
This request replaces the attribute's top-level fields with the new definition provided in the request body.
In the request body, forms
contains the detailed definition of a list of attribute forms. Each attribute contains one or more attribute forms.
Each attribute form contains:
expressions
: A list of attribute form expressions. Attribute form contains one or more attribute form expressions. Each attribute form expression containsexpression
andtables
.- ”expression”: Needs to be in either
tree
ortokens
format.- Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say an attribute form expression is
Year - 10
. When the attribute form expression is represented as tokens, the text is broken down into pieces (tokens) with information about what these pieces represent in the metadata: (Year_ID
, YearcolumnID), (-
, Minus_ID), (10
, Constant).
- Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say an attribute form expression is
tables
: A list of tables that theexpression
applies to. Warehouse partition base tables and metadata partition mapping tables are not allowed here.
- ”expression”: Needs to be in either
dataType
andalias
are optional. If omitted, they are calculated based on the first attribute form expression.childForms
is specific to a form group, which contains the reference for child forms
Provide a lookup table on either the attribute level or attribute form level, as it is required for the object to be committed to the metadata. A lookup table can be defined on the attribute level using attributeLookupTable
, or the attribute form level using lookupTable
. If LookupTable
is defined at the attribute form level, it is used, or it falls back to attributeLookupTable
. Warehouse partition base tables and metadata partition mapping tables are not allowed to use in the lookup table.
Provide keyForm
and displays
, as they are required for the object to be committed to the metadata.
The changeset ID can be obtained using the changeset creation API. An authorization token is required to execute the request and can be obtained using Authentication endpoints.
To save the newly updated attribute to the metadata, commit using the changeset commit API.
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
showExpressionAs | string | This parameter specifies the format in which the expressions are returned in response. |
This parameter applies to the expressions in a fact or attribute, and custom expressions used in a filter, prompt, or security filter.
Expressions are presented in the following formats:
-
"text": A human readable, but non-parsable text, describing the expression. This is the default format that is always returned in the response.
-
"tree": A tree data structure fully defining the expression. This format can be used if you want to examine and modify the expression programmatically.
-
"tokens": A list of parsed tokens. This format can be used if you want to examine and modify the expression using the parser component. Note that generating tokens requires additional time.
Tokens are a semi-structured representation of MicroStrategy expression text that includes object references. For example, let’s say a filter expression is "Revenue > Cost". When the filter expression is represented as tokens, the text is broken down into pieces (tokens) with information about what these pieces represent in the metadata: ("Revenue", Revenue_ID), (">", GreaterThan_ID), ("Cost", Cost_ID).
If omitted, the expression is returned in "text" format.
If tree
, the expression is returned in "text" and "tree" formats.
If tokens
, the expression is returned in "text" and "tokens" formats.
|
| showPotentialTables
| boolean | | This parameter specifies whether to return the potential tables that the expressions can be applied to.
If true
, the "potentialTables" field returns for each fact/attribute expression, in the form of a list of tables.
If false
or omitted, the "potentialTables" field is omitted.
|
| showFields
| string | | Specify what additional information is returned.
Only "acl" is supported.
- If
acl
, the access control list for each object is included. | |removeInvalidFields
| boolean | | This parameter specifies whether to check and remove the invalid fields caused by changes related to key form within the request.
Changes related to key form could introduce invalid expressions for non-key forms as expression's table is empty, and/or invalid relationship as the relationship table is null.
If omitted or false
, only "text" and "tree" formats are returned.
If true
, if the key form changes in the request introduce invalid expressions and/or relationships,
the invalid expressions and/or relationships are removed from the attribute and/or the system hierarchy.
If false
or omitted, it errors out if the key form changes in the request introduce invalid expressions and/or relationships.
|
| fields
| null | | A whitelist of top-level fields separated by commas.
This parameter allows the client to selectively retrieve fields in the response.
Once specified, only the listed fields are returned in the response. For example, if this parameter is set as “information, expressions”, only “information” and “expressions” are returned. Other top-level fields are omitted. |
Request Body
{"information"=>{"subType"=>"attribute", "name"=>"Subcategory Modified", "destinationFolderId"=>"{{publicReportsFolderId}}"}, "forms"=>[{"name"=>"ID", "description"=>"Subcategory ID", "category"=>"ID", "displayFormat"=>"number", "expressions"=>[{"expression"=>{"tokens"=>[{"value"=>"SUBCAT_ID"}]}, "tables"=>[{"objectId"=>"76C6FEAB49D08F57BC6FC9B644743EEF", "subType"=>"logical_table", "name"=>"CITY_SUBCATEG_SLS"}, {"objectId"=>"8D67937411D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_ITEM"}, {"objectId"=>"8D6793B611D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_SUBCATEG"}]}], "alias"=>"SUBCAT_ID", "lookupTable"=>{"objectId"=>"8D6793B611D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_SUBCATEG"}}, {"name"=>"DESC", "description"=>"Subcategory Name", "category"=>"DESC", "isMultilingual"=>true, "displayFormat"=>"text", "expressions"=>[{"expression"=>{"tokens"=>[{"value"=>"SUBCAT_DESC"}]}, "tables"=>[{"objectId"=>"8D6793B611D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_SUBCATEG"}]}], "alias"=>"SUBCAT_DESC", "lookupTable"=>{"objectId"=>"8D6793B611D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_SUBCATEG"}}], "attributeLookupTable"=>{"objectId"=>"8D6793B611D3E4981000E787EC6DE8A4", "subType"=>"logical_table", "name"=>"LU_SUBCATEG"}, "keyForm"=>{"name"=>"ID"}, "displays"=>{"reportDisplays"=>[{"name"=>"DESC"}], "browseDisplays"=>[{"name"=>"DESC"}]}, "sorts"=>{"reportSorts"=>[{"form"=>{"name"=>"DESC"}, "ascending"=>true}], "browseSorts"=>[{"form"=>{"name"=>"DESC"}, "ascending"=>true}]}}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
X-MSTR-AuthToken | string | (Required) Authorization Token | |
X-MSTR-MS-Changeset | string | (Required) Changeset ID | |
Content-Type | string |