DMN model rule that can loop custom data type list

917 Views Asked by At

I have a data structure similar to below json example and I would like to loop through nested list to get "DetailType" , check if a single "DetailType" is "ABC" then don't check rest of the Accounts and return true. How can this be modeled in DMN. Basically if customer has a single account that has "DetailType" = "ABC" then its a valid customer.

"Customer Profile" : {
  "customer" : {
    "customerName" : "gjhjhkj",
    "Accounts" : [ {
      "Number" : "pWYSk93jiL",
      "accountDetails" : [ {
        "DetailDesc" : "sdfdsff",
        "DetailType" : "4354355435",
      }, {
        "DetailDesc" : "Mr7GQRzcc0",
        "DetailType" : "JERV3kQZFR",
      }
    } ]
  }
}
2

There are 2 best solutions below

0
On BEST ANSWER

Using FEEL, you could write something along the lines of:

some DetailType in Customer Profile.customer.Accounts[accountDetails][DetailType] satisfies DetailType = "ABC"

but the question as it was originally posted is missing to show on any attempt to do it with an example DMN, so there are a lot of other requirements which need clarification to provide a full working solution.

Definitely the expression above is a valid FEEL expression which address the question as originally posted.

0
On

I have similar issue.

I tried suggested solution to find out if there are some licence status = "DFT" but it is not working.

End up with below exception when evaluating the DMN:

failed to evaluate expression 'some licStat in party.partyCategories[partyLicences][status] satisfies licStat ="DFT"': Expected boolean filter or number but found 'ValList(List(ValContext(StaticContext(Map(entityId -> ValNumber(3), status -> ValString(DFT)),Map()))))'

Question is still open. How to query deep structures using FEEL?

Below is the example I work on:

some licStat in party.partyCategories[partyLicences][status] satisfies licStat ="DFT"

Having the structure:

        "party": {
            "value": { 
                "partyCategories": [
                    {
                        "entityId": 3,
                        "status": "ACT",
                        "partyLicences": [
                            {
                                "entityId": 3,
                                "status": "DFT"
                            }
                        ]
                    },
                    {
                        "entityId": 1,
                        "status": "DFT",
                        "partyLicences": [
                            {
                                "entityId": 3,
                                "status": "ACT"
                            },
                            {
                                "entityId": 3,
                                "status": "DFT"
                            }
                        ]
                    }
                ]
            }
        }