List of Variables Returns Empty

I have a process model where it inserts into the database for each record. One of the rows I try to insert returns a "List of Variant" with 0 items. Now on insertion, the process model skips that row and goes to the next one and adding it to the wrong row to the current user row. Also some of the dictionaries have a property that changes the values from "short" to "long". I used the property() function to make it where if the first is missing (short), then the other returns (long). But instead of returning the other one, it returns null and inserts into the DB as null. When I use the flatten() function on the results, the "List of Variants" get skipped as well and then instead of the 100 rows it shows, I get 94 (six are like the last code example)

Here is a partial string of the response:

{
    user : {
        assignment: [
            {
                primary:true,
                homeUnit: [
                    {
                        nameCode: { codeValue: "1", shortName: "analyst"},
                        typeCode: { codeValue: "role", shortName: "role"}
                    },
                    {
                        nameCode: { codeValue: "m01", shortName: "math"},
                        typeCode: { codeValue: "dept", shortName: "dept"}
                    }
                ]
            },
            {
            primary: false,
            ...
            }
        ]
    },
    user : {
        assignment: [
            {
                primary:true,
                homeUnit: [
                    {
                        nameCode: { codeValue: "2", shortName: "engineer"},
                        typeCode: { codeValue: "role", shortName: "role"}
                    },
                    {
                        nameCode: { codeValue: "s101", shortName: "science"},
                        typeCode: { codeValue: "dept", longName: "dept"} /* notice longName instead of shortName */
                    }
                ]
            }
        ]
    },
    user : {
        assignment:[ {primary:true}, {primary:false}] /* causing List of Variant - 0 items */
    }
}

Here is the response handler:

index(
a!forEach(
    items: local!response.body.user.assignment.homeUnit
      , expression: if(
        wherecontains("role",touniformstring(fv!item.typeCode.shortName))
        ,property(fv!item.nameCode,"shortName",fv!item.nameCode.longName),"") /*doesn't work*/
    )
    ,where(local!response.body.user.assignment.isPrimary),"")
    
    )

As mentioned before, this is the what returns a List of Variants with 0 items:

assignment : [
    {primary: true},{primary:false}
]

Is this by design with the function to make it skip if it's a List of Variant type? Or how may I convert the List of Variant to an empty string in order to insert a blank value into the DB? Also why doesn't the property() function catch the other alternative property name (valueIfMissing)? 

  Discussion posts and replies are publicly visible