I'm trying to dynamically populate an attribute enumerated list based on another attributes values in IBM DOORS.
the image represent the list of items defined as object text
I want to dynamically update type enum based on the list captured in the picture as "Configuration Item 1", "Configuration Item 2"...
The user add/update a configuration item, then a previously defined enumurated type gets automatically updated with the same addition/update.
sure, it's possible. Basically you need to define several arrays, among them are
and with these arrays you use perm AttrType modify(AttrType at, string name, [string codes[], int values[], int colors[], string descs[] string URI[], [int arrMaps[],]] string &errMess)
command on attribute types.
Attached is a script from our library that copies enumerations from one module to another - this might be helpful as a starting point for your script. Also, there's an example how to modify attribute types in the DXL Reference manual, look for "modify(attribute type)" in the chapter "Attribute Type manipulation"
void updateEnumeration__(AttrType sat, at, Module targm)
// AttrType sat, // IN: original (source) type
// AttrType at, // IN: copy (target) type, null if none exists yet
// Module targm) // IN: target module
//
// DESCRIPTION: Creates a copy of the type sat in the target module targm.
// If a copy already exists ('at'), it is updated. Any enumerations
// which are in the copy and have been removed from the source type
// are kept in the copy, to prevent errors in reading attribute
// values which use these enumerations in the target module.
{
string errmess = ""
int enumerationSize = sat.size
int index, oldIndex
if (!null at)
{
// Work out the size of the merged enumerations list
for (oldIndex = 0; oldIndex < at.size; oldIndex++)
{
if (matchIndex(at.strings[oldIndex], sat) == -1)
{
// Add one for each old name which isn't used
enumerationSize++
}
}
}
string enumNames[enumerationSize]
int enumValues[enumerationSize]
int enumCols[enumerationSize]
Module savedModule = current
current = targm
bool bRealColours = getRealColorOptionForTypes()
setRealColorOptionForTypes(true)
for (index = 0; index < sat.size; index++)
{
enumNames[index] = sat.strings[index]
enumValues[index] = sat.values[index]
enumCols[index] = sat.colours[index]
}
if (null at)
{
at = create(sat.name "", enumNames, enumValues, enumCols, errmess)
if (errmess != "")
{
reportError("typeError", "Cannot create attribute type " (sat.name "") " : " errmess);
}
}
else
{
// Add any unused old enumerations to the end of the merged list
oldIndex = 0
while (index < enumerationSize)
{
// Skip enumerations which are still used
while (matchIndex(at.strings[oldIndex],sat) != -1)
{
oldIndex++
}
// copy the next unmatched old enumeration
enumNames[index] = at.strings[oldIndex]
enumValues[index] = at.values[oldIndex]
enumCols[index] = at.colours[oldIndex]
oldIndex++
index++
}
// Populate the index mapping array
int enumOldIndices[enumerationSize]
for (index = 0; index < enumerationSize; index++)
{
enumOldIndices[index] = matchIndex(enumNames[index],at)
}
// Ready to go: update the type definition...
modify(at, sat.name "", enumNames, enumValues, enumCols, enumOldIndices, errmess)
if (errmess != "")
{
reportError("typeError", "Cannot modify attribute type " (sat.name "") " : " errmess);
}
}
setRealColorOptionForTypes(bRealColours)
current = savedModule
} // updateEnumeration__