Using MDM Java APIs to add Text(type) taxonomy attribute allowable values
Now consider this a continuation of my previous blog on MDM Java APIs (taxonomy attributes):
Using MDM Java APIs to retrieve Taxonomy attribute Values – this was while attempting to replicate all capabilities of MDM Data Manager using MDM Java APIs.
During the same exercise I had made up my mind, to develop a highly customised data manager using MDM Java APIs & Portal UI technologies. As of now, my Custom Data Manger is under build and would have to wait before I share the same with the community.
For now, I am sharing the following solution for the scenario, which propped up as a result of brief conversation over a cup of Tea.
“MDM Taxonomy attributes can have a set of allowable values for taxonomy attributes of type text for e.g. different country names for attribute ‘Country’, different values for attribute ‘type’ of a Material etc.While MDM Data Manger provides option to add allowable values for a Taxonomy attribute at design time, which are utilised in custom built MDM – Portal applications or MDM Business packages. What if the user wants to add a value to the set of allowable values for a text type taxonomy attribute at runtime? , which would enable him an additional option to select from a list of allowable values for a Taxonomy attribute. I couldn’t find an out of the box set of API methods/Interfaces, which can help us achieve the same”
After a lot of analysis and indepth study of MDM Java APIs, I could find out a mechanism using which we can replicate this design time functionality of MDM Data Manager, at runtime by using MDM Java APIs.
The algo/code snippet given below can be re-used, after further customizing or extending as is needed.
We start at the point where we have retrieved the attribute object (retrieved using Attribute ID, which in turn is retrieved from current record object, refer embedded blog link for details)
Depending upon the screen design i.e. the number of entries you want the end user to enter for addition to list of allowable values for text type taxonomy attribute one can utilize the following lines of code.
int textAttrValueCount = 10; // allows the user to add 10 values to the set of allowable values for a text type taxonomy attribute
for (int i = 0; i<textAttrValueCount; i++)
TextAttributeValueProperties textValue = new TextAttributeValueProperties();
baseName = “TextValue” + i + System.currentTimeMillis();
MultilingualString textValueName = MultilingualHelper.createMultilingualString(regDefs, baseName);
baseName = “Tooltip” + i + System.currentTimeMillis();
MultilingualString tooltip = MultilingualHelper.createMultilingualString(regDefs, baseName);
attr = text type taxonomy attribute object to which allowable values are to be added
Utilizing the code piece or the approach outlined above one can customize and extend MDM Business Packages (so that it gives end user the option to add to allowable values for a text type taxonomy attribute)or integrate the same into a webdynpro application providing cover to MDM repository and give end user the option which is otherwise available on at design time i.e. using MDM Data Manager.