Skip to main content

Attribute element prompts

tip

You can try out this workflow at REST API Playground.

Learn more about MicroStrategy REST API Playground here.

An attribute element prompt is one of the most commonly used prompt types. It allows the caller to provide a list of attribute elements from which a selection is made. For example, you can define a prompt as "Call Center in USA".

Use REST APIs to perform the following actions on attribute element prompts:

Create a new prompt

  1. To create an attribute element prompt, you must enter the required fields with the correct information, using POST /api/model/prompts.

  2. The response can change based on the request parameters provided by the caller. Use the following parameters.

    LocationNameDescription
    headerX-MSTR-authTokenThe authorization token
    headerX-MSTR-ProjectIDThe ID of the project
    headerX-MSTR-MS-ChangesetThe ID of the changeset
    queryshowExpressionAsThe parameter that specifies the format in which the response is returned.
  3. The model for the definition of an attribute element prompt can be represented using the fields shown below. "objectID", "dateCreated", "dateModified", and "versionId" are automatically generated.

    FieldsNameDescriptionData TypeRequired?
    informationnameThe name of the prompt. This should be a user-friendly name for identifying the prompt.string✔️
    informationsubTypeThe type of prompt. The "subType" for an attribute element prompt is "prompt_elements".string✔️
    informationdestinationFolderIdThe folder ID where the new prompt is saved.string✔️
    titleThe title of the prompt.string
    instructionThe instruction on how to apply the prompt.string
    questionattributeThe attribute to apply this attribute element prompt to.string✔️
    questionlistAllElementsAn indicator that specifies if are elements are used for the prompt. If this is set to True, "predefinedElements" and "filter" should be null. Otherwise, the response returns an error.boolean
    questionpredefinedElementsA list of predefined elements with "display" and "elementId".string
    questionfilterA standalone filter object with "objectId", "subType", and "name". When "listAllElements" is False, "filter" and "predefinedElements" should have an XOR relationship, since only one of them has a value.string
    defaultAnswerelementsA list of elements used as a default answer. Each element should include "display" and "elementId".string
    restrictionrequiredAn indicator that specifies whether a prompt answer is required or not.boolean
    restrictionallowPersonalAnswersAn indicator that specifies whether personal answers are allowed. It can be set to "none", "single", or "multiple".string
    restrictionminThe minimum number of elements that can be selected.integer
    restrictionmaxThe maximum number of elements that can be selected.integer

    Sample code for creating an attribute element prompt's definition is provided below.

    {
    "information": {
    "destinationFolderId": "8A1831FF494F528D02A4A8BF5FB73459",
    "subType": "prompt_elements",
    "name": "Call Center In USA"
    },
    "title": "Call Center In USA",
    "instruction": "Choose elements of Call Center.",
    "question": {
    "attribute": {
    "objectId": "8D679D3511D3E4981000E787EC6DE8A4",
    "subType": "attribute",
    "name": "Call Center"
    },
    "listAllElements": false,
    "filter": {
    "objectId": "4C46C8CB43D1BCD0347E10BA3004E70D",
    "subType": "filter",
    "name": "CountryInUSA"
    }
    },
    "defaultAnswer": {
    "elements": [
    {
    "display": "San Diego",
    "elementId": "h2"
    },
    {
    "display": "San Francisco",
    "elementId": "h4"
    },
    {
    "display": "Salt Lake City",
    "elementId": "h6"
    }
    ]
    },
    "restriction": {
    "required": false,
    "allowPersonalAnswers": "none",
    "min": 2,
    "max": 5
    }
    }

Update an existing prompt

  1. Update the definition of the attribute element prompt using PUT /api/model/prompts/{promptId}.

  2. Provide the following headers in the request:

    LocationNameDescription
    headerX-MSTR-authTokenThe authorization token
    headerX-MSTR-ProjectIDThe ID of the project
    headerX-MSTR-MS-ChangesetThe ID of the changeset
    queryshowExpressionAsThe parameter that specifies the format in which the response is returned.
  3. In addition to the above header, you should also provide the ID of the prompt you want to update.

  4. You can modify the fields shown below. The "subType" field is not included below since it cannot be modified through this REST API.

    FieldsNameDescriptionData Type
    informationnameThe name of the prompt. This should be a user-friendly name for identifying the prompt.string
    informationdestinationFolderIdThe folder ID where the new prompt is saved.string
    titleThe title of the prompt.string
    instructionThe instruction on how to apply the prompt.string
    questionattributeThe attribute to apply this attribute element prompt to.string
    questionlistAllElementsAn indicator that specifies if are elements are used for the prompt. If this is set to True, "predefinedElements" and "filter" should be null. Otherwise, the response returns an error.Boolean
    questionpredefinedElementsA list of predefined elements with "display" and "elementId".string
    questionfilterA standalone filter object with "objectId", "subType", and "name". When "listAllElements" is False, "filter" and "predefinedElements" should have an XOR relationship, since only one of them has a value.string
    defaultAnswerelementsA list of elements used as a default answer. Each element should include "display" and "elementId".string
    restrictionrequiredAn indicator that specifies whether a prompt answer is required or not.Boolean
    restrictionallowPersonalAnswersAn indicator that specifies whether personal answers are allowed. It can be set to "none", "single", or "multiple".string
    restrictionminThe minimum number of elements that can be selected.integer
    restrictionmaxThe maximum number of elements that can be selected.integer