Engineering Requirements Management

Engineering Requirements Management

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

Set enumeration value based on value in another attribute

  • 1.  Set enumeration value based on value in another attribute

    Posted Mon October 26, 2020 05:03 PM

    Hi,

    I'm have an existing column "Justify-old" that was previously a free text column. I have created a new enumeration column "Justify" with values "Safety" , "Technical", "Information", "Redundant".

    I want to create dxl that will review the values currently in column "A" and pick a enumeration value in column "B" based on those words. i.e. if column "A" contains the word "Safety" (ignoring case of the word) it will populate the enumeration with the value "Safety".

    I have put the "If(exists" in as I have previous DXL to create the new "Justify" enumeration column.

    I tried the following but no luck:

    Module m = current

    Object o = null

    for o in m do{

    if (exists attribute "Justify")

    justOld = o."Justify-old" ""

    if findPlainText(justOld, "Safety", offset, length, false, false){

    o."Justification" = "Safety"

    }

    elseif findPlainText(justOld, "Technical", offset, length, false, false){

    o."Justifiacation" = "Technical"

    }

    elseif findPlainText(justOld, "Information", offset, length, false, false){

    o."Justifiacation" = "Information"

    }

    elseif findPlainText(justOld, "Redundant", offset, length, true, false){

    o."Justifiacation" = "Redundant"

    }

    elseif findPlainText(justOld, "", offset, length, true, false){

    o."Justifiacation" = ""

    }

    }





    #Support
    #EngineeringRequirementsManagement
    #SupportMigration
    #DOORS
    #Sustainability


  • 2.  RE: Set enumeration value based on value in another attribute

    Posted Tue October 27, 2020 04:09 PM

    I don't have those attributes so I can't test it but I think you have some gaps in your code. I think this should work:

    pragma runLim, 0 Module m = current Object o = null for o in m do{ int offset, length if(null != find(m, "Justify")){ string justOld = probeAttr_(o, "Justify-old") if(!null justOld){ if(findPlainText(justOld, "Safety", offset, length, false)){ o."Justification" = "Safety" }else if(findPlainText(justOld, "Technical", offset, length, false)){ o."Justifiacation" = "Technical" }else if(findPlainText(justOld, "Information", offset, length, false)){ o."Justifiacation" = "Information" }else if(findPlainText(justOld, "Redundant", offset, length, false)){ o."Justifiacation" = "Redundant" } }else{ o."Justifiacation" = "" } } }



    #SupportMigration
    #EngineeringRequirementsManagement
    #Sustainability
    #Support
    #DOORS