Learner
Learner

Reputation: 93

DXL filter using if else loop

I am using Door 9.6 and trying to create a generic filter which can be used for multiple documents in my project. The project documents have an attribute "Requirement Type". This attribute can have value as "Functional", "Non Functional", "Information" etc. The documents are not uniform and some of the documents have "Requirement Type" as "Functional", "Information" . I am trying to use attributeValue() to find out this variation but somehow couldn't figure out the issue in the code.

-E- DXL: <Line:16> incorrect arguments for (||)
-E- DXL: <Line:16> incorrect arguments for (||)
-E- DXL: <Line:16> undeclared variable (f1)
-E- DXL: <Line:16> incorrect arguments for (=)

Here is the code

Module m = current
load view("default view")

AttrDef ad = find(current Module, "Requirement Type")

    if (attributeValue(ad, "Non functional")){
        Filter f1 = contains(attribute "Requirement Type", "Non Functional", false)
    }
    else {
        Filter f1= contains(attribute "Requirement Type", "Functional", false)
    }

    Filter f2= contains(attribute "Requirement Type", "Information", false)
    Filter f3= contains(attribute "Requirement Type", "Functional", false)

    Filter set_f = f1 || f2 || f3
    set(current Module, set_f)

Upvotes: 0

Views: 809

Answers (1)

Mike
Mike

Reputation: 2346

When a variable is declared inside { brackets }, the variable will not be visible from the outside. Declare it outside the brackets, but set them inside.

Module m = current
load view("default view")

AttrDef ad = find(current Module, "Requirement Type")

Filter f1
if (attributeValue(ad, "Non functional")){
    f1 = contains(attribute "Requirement Type", "Non Functional", false)
}
else {
    f1= contains(attribute "Requirement Type", "Functional", false)
}

Filter f2= contains(attribute "Requirement Type", "Information", false)
Filter f3= contains(attribute "Requirement Type", "Functional", false)

Filter set_f = f1 || f2 || f3
set(current Module, set_f)

Upvotes: 1

Related Questions