ForEach Expression Rule not returning list as desired. Please advise.

Below is the expression rule. 

a!forEach(
items: ri!NSARequest.SelectedApprovalTeams,
expression: {
if(rule!NSA_GetStatusOfApprovalTeam_ExprRule(ri!NSARequest, fv!item) = "Pending", fv!item, null)
}
)

 

Rule Input Value being passed in Test Case:

{
AAGRequest: {Status: "Pending"},
OGCRequest: {Status: "Completed"},
SelectedApprovalTeams: {
cons!NSA_AAG_Name_Cons,
cons!NSA_OGC_Name_Cons
}
}

It is returning null and count 2 even if the input list passed has only one "Pending" status request. 

List of Variant: 2 items List of Text String: 1 item "Architecture Assurance Group" List of Text String: 1 item null (Text)

 

  Discussion posts and replies are publicly visible

Parents
  • It's not clear what you're asking.

    If you want to return the following, just get rid of the curly braces following expression in the a!foreach loop.

    List of Text String: 2 items
        "AAGRequest"
        null (Text)

     

    If you want to get rid of the null entry, clean up the resulting list using something like reject(fn!isnull, local!list).

  • +1
    Certified Lead Developer
    in reply to Carlos Santander
    Hello,

    The reason why you are getting 2 values. Is because you are looping SelectedApprovalTeams, which actually has 2 values.

    The reason to get null values is that the rule NSA_GetStatusOfApprovalTeam_ExprRule each time is not returning pending, consequently it goes to the falseValue of the “ir function” which has null value.

    That is definitely a normal behavior. You can use Carlos suggestion on the reject or filter, or pass {} instead of null and use flatten.

    José
Reply
  • +1
    Certified Lead Developer
    in reply to Carlos Santander
    Hello,

    The reason why you are getting 2 values. Is because you are looping SelectedApprovalTeams, which actually has 2 values.

    The reason to get null values is that the rule NSA_GetStatusOfApprovalTeam_ExprRule each time is not returning pending, consequently it goes to the falseValue of the “ir function” which has null value.

    That is definitely a normal behavior. You can use Carlos suggestion on the reject or filter, or pass {} instead of null and use flatten.

    José
Children
No Data