Create custom attributes that uses multiple choices in Microsoft Purview

Posted by

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

We know that Managed attributes in Microsoft Purview is helpful to enrich technical assets and help a data consumer get more context about the asset to which it is applied.

 

In order to create these Managed Attributes, the Purview UI does a very good job and is probably the easiest and recommended  approach. At the same time, Purview also offers the flexibility to create them using APIs. Here is an example: Use new APIs available with Atlas 2.2. - Microsoft Purview | Microsoft Learn

 

But, I was looking for a way to create an attribute that uses multiple choice in the “Field type” rather than using the text (from the example in the link above). Below is an approach that worked for me (thanks to a few colleagues that helped).

 

The approach involves 2 typeDef API calls:

 

Create a ENUM typeDef: (this step is optional if you already have the ENUM created)

 

POST: api/atlas/v2/types/typedefs

{

    "enumDefs": [

        {

            "name": "ATTRIBUTE_ENUM_CUSTOMNAME",

            "elementDefs": [

                {

                    "value": "choice1",

                    "ordinal": 0

                },

                {

                    "value": "choice2",

                    "ordinal": 1

                },

                {

                    "value": "choice3",

                    "ordinal": 2

                }

            ]

        }

    ]

}

Create/Update Business MetaData typedef:

 

POST/PUT api/atlas/v2/types/typedefs

  {    "businessMetadataDefs":
    [
        {
            "category": "BUSINESS_METADATA",
            "name": "<Managed Attribute group name to be created>",
            "description": "<Any description>",
            "attributeDefs":
            [
                {
                    "cardinality": "SINGLE",
                    "isUnique": false,
                    "options":
                    {
                        "applicableEntityTypes": "[\"Asset\"]"
                    },
                    "name": "multi_choice_attr",
                    "typeName": "array<ATTRIBUTE_ENUM_CUSTOMNAME>",
                    "isOptional": true
                }
            ]
        }
    ]
}

Note: The prefix "ATTRIBUTE_ENUM_" is mandatory for now. The output in the UI should look like the below:

MultipleChoice.jpg

Once created, you should now be able to assign the above attribute to assets.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.