IBM Doors DXL: Delete and Create Attributes for Doors Module

Problem

An Attribute shall be deleted and replaced (recreated) by the same attribute with another type.

Approach

– Delete old attribute
– Create new one
– Views will not get lost with this method!

Solution

void deleteAttrDef(Module m, string s)
{
  string err;
  AttrDef ad = find(m, s);
  err = delete(ad);
  if (err !="") ack err;
} 

void modifyAttributeType(Module m, string theAttribute, string newAttributType)
{
  current = m;
	
  // Delete Attribute attribute1 if exists
  if (exists(attribute(string theAttribute))) 
  {	
    deleteAttrDef(m, theAttribute);
  }
	
  // Create new attribute1 of type TEXT (not string)
  AttrDef ad = create object type newAttributType attribute theAttribute
		
  if (null ad)
  {
    print "attr didn't create for module " fullName(m) "\n";
    halt;
  }			
}

modifyAttributeType(current Module, "My_Attribut_To_Change_Type", "Text");

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.