a!localVariables( local!reassigndetail: a!queryEntity( entity: cons!MPPCONSDSE_MPPTABSAM_task, query: a!query( selection: a!querySelection( columns: { a!queryColumn( field: "ReassignEmail" ), a!queryColumn( field: "samaccid" ) } ), logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "Reassign", operator: "=", value: "Yes" ), a!queryFilter( field: "annoucncementid", operator: "=", value: ri!Announcementid ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: -1 ) ), fetchTotalCount: false ).data, local!fabdetails: a!forEach( items:local!reassigndetail, expression:rule!MPPER_getFabsnamefromsamaccid(fv!item.samaccid) ), local!fabdetails2: a!forEach(a!flatten( local!fabdetails).fabname,fv!item), local!samemails: a!forEach(a!flatten( local!reassigndetail).ReassignEmail,fv!item) , local!samdata : a!queryEntity( entity: cons!MPPCONSCDT_SAMAccountability, query: a!query( logicalExpression: a!queryLogicalExpression( operator: "AND", filters: { a!queryFilter( field: "samemail", operator: "in", value:local!samemails ), a!queryFilter( field: "fabname", operator: "in", value:local!fabdetails2 ) }, ignoreFiltersWithEmptyValues: true ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 50 ) ), fetchTotalCount: false ).data, local!result: a!forEach( items:local!samdata, expression: cast(typeof('type!{urn:com:appian:types}MPPSAMAccoumtability'()),fv!item) ), local!result )
this works fine if local!reassigndetail finds some data from DB using a!queryentity but when it doesn't return any data from db then it gives following error
Expression evaluation error at function a!forEach [line 47]: Invalid index: Cannot index property ’’fabname’’ of type String into type List of Variant
Please help
Discussion posts and replies are publicly visible
it returns list
List of what / what is the structure of the list returned? Because your subsequent code assumes that local!fabDetails is a dictionary containing a property named fabName.
List of dictionary .
Flatten takes : {{1,2,3},{4},{},{5,6,7,8},{{9},{10,11}},12} and outputs {1,2,3,4,5,6,7,8,9,10,11,12}. It makes a nested array of arrays into just an array. Do you even need that operation to be performed if you have a list of dictionary?
What does flatten() do to a list of dictionary? Would it similarly squash the internal structure so you couldn't see the individual fields anymore?
Unknown said:What does flatten() do to a list of dictionary?
AFAIK it just makes sure it's a flatt array of dictionary, instead of a list of nested lists. I believe it's being used redundantly (or at least, unnecessarily) in the above code sample.