Skip to main content
April 18, 2024
Question

[Expression evaluation error at function 'reject' [line 39]: Incorrect number of parameters for function; expected 1 parameters, but found 0 parameters.]

  • April 18, 2024
  • 16 replies
  • 0 views

Hi All

I am getting the error with reject function so please let me know what causing this error .

 [Expression evaluation error at function 'reject' [line 39]: Incorrect number of parameters for function; expected 1 parameters, but found 0 parameters.]

a!localVariables(
  local!group: index(
    rule!CDM2_findUserGroup(loggedInUser()),
    1,
    {}
  ),
  local!escalatedTo: if(
    a!isNullOrEmpty(local!group),
    {},
    index(
      a!queryEntity(
        entity: cons!CDM2_DSE_INQUIRIES,
        query: a!query(
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(field: "escalatedTo", isGrouping: true)
            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "groupId",
                operator: "=",
                value: local!group
              )
            },
            ignoreFiltersWithEmptyValues: false
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      "escalatedTo",
      null()
    )
  ),
  local!tmodData: 
  reject(fn!isnull,
  a!forEach(
    items: local!escalatedTo,
    expression: if(
      a!isNullOrEmpty(fv!item),
      {},
      if(
        not(isusernametaken(fv!item)),
        fv!item,
        null()
      )
    )
  )),
  local!tmodGivenNames: if(
    a!isNotNullOrEmpty(local!tmodData),
    index(
      a!queryEntity(
        entity: cons!TMODS_DSE,
        query: a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(field: "given_name"),
              a!queryColumn(field: "preferred_given_name"),
              a!queryColumn(field: "enterprise_login_id"),

            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "enterprise_login_id",
                operator: "IN",
                value: upper(local!tmodData)
              )
            },
            ignoreFiltersWithEmptyValues: true
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      null()
    ),
    {}
  ),  
  local!groupMembers:a!forEach(
    items:  local!escalatedTo,
    expression: if(
      a!isNullOrEmpty(fv!item),
      {},
      if(
        not(isusernametaken(fv!item)),
        {
          xid: fv!item,
          name: a!localVariables(
            local!blankTmodGivenName: displayvalue(
              upper(fv!item),
              touniformstring(
                local!tmodGivenNames.enterprise_login_id
              ),
              if(                
                /*a!isNullOrEmpty(local!tmodGivenNames.preferred_given_name),*/
                a!isNullOrEmpty(index(local!tmodGivenNames.preferred_given_name,wherecontains(upper(fv!item),touniformstring(local!tmodGivenNames.enterprise_login_id)),{})),
                local!tmodGivenNames.given_name,
                local!tmodGivenNames.preferred_given_name
              ),
              {}
            ),
            if(
              a!isNullOrEmpty(local!blankTmodGivenName),
              fv!item,
              local!blankTmodGivenName
            )
          )
        },
        {
          xid: fv!item,
          name: user(fv!item, "firstName") & " " & user(fv!item, "lastName")
        }
      )
    )
  ),  
  a!recordFilterList(
  name: "Escalated To",
  isVisible: a!isNotNullOrEmpty(local!groupMembers),
  options: a!forEach(
  items: local!groupMembers,
  expression:a!recordFilterListOption(
  id: fv!index,
  name: fv!item.name,
  filter: a!queryFilter(
  field:'recordType!{92bc5c32-2509-4558-b252-56df608deb1a}CDM2 Inquiries.fields.{escalatedTo}escalatedTo',
  operator: "=",
  value: fv!item.xid
  )
  )
  )
  )
)

I am geeting the error in reject function when the "AssignTo" is null

16 replies

mikes0011
Brainy
April 18, 2024

Your syntax for "reject()" looks correct, other than maybe some more subtle error with the local variables.

But I'm here to say you don't need it in this context.  a!forEach() can handle it on its own.  For the negative case just make it return the empty set, {}, instead of null().

(There is one corner case where if *every* entry returned by the a!forEach() statement is an empty set, you get a list of empty sets (otherwise you get a list of all the good items and empty sets are ignored in the output), so to prevent this you would also want to wrap the entire a!forEach() call in a!flatten().)

shubhama926776
April 18, 2024

 [mention:b04813dcb78a48ff889e6fbdf057c6bc:e9ed411860ed4f2ba0265705b8793d05]  Can you try this code and let me know if that works for you.

a!localVariables(
  local!group: index(
    rule!CDM2_findUserGroup(loggedInUser()),
    1,
    {}
  ),
  local!escalatedTo: if(
    a!isNullOrEmpty(local!group),
    {},
    index(
      a!queryEntity(
        entity: cons!CDM2_DSE_INQUIRIES,
        query: a!query(
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(field: "escalatedTo", isGrouping: true)
            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "groupId",
                operator: "=",
                value: local!group
              )
            },
            ignoreFiltersWithEmptyValues: false
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      "escalatedTo",
      null()
    )
  ),
  local!tempTmodData:a!flatten( a!forEach( 
    items: local!escalatedTo,
    expression: if(  
      a!isNullOrEmpty(fv!item),
      {}, 
      if(
        not(isusernametaken(fv!item)),
        fv!item,
        null()
      )
    )
  )
  ),
  local!tmodData: if(  
    a!isNotNullOrEmpty(local!tempTmodData), 
    reject(fn!isnull, local!tempTmodData),  
    {}  
  ),
  local!tmodGivenNames: if(
    a!isNotNullOrEmpty(local!tmodData),
    index(
      a!queryEntity(
        entity: cons!TMODS_DSE,
        query: a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(field: "given_name"),
              a!queryColumn(field: "preferred_given_name"),
              a!queryColumn(field: "enterprise_login_id"),

            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "enterprise_login_id",
                operator: "IN",
                value: upper(local!tmodData)
              )
            },
            ignoreFiltersWithEmptyValues: true
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      null()
    ),
    {}
  ),  
  local!groupMembers:a!forEach(
    items:  local!escalatedTo,
    expression: if(
      a!isNullOrEmpty(fv!item),
      {},
      if(
        not(isusernametaken(fv!item)),
        {
          xid: fv!item,
          name: a!localVariables(
            local!blankTmodGivenName: displayvalue(
              upper(fv!item),
              touniformstring(
                local!tmodGivenNames.enterprise_login_id
              ),
              if(                
                /*a!isNullOrEmpty(local!tmodGivenNames.preferred_given_name),*/
                a!isNullOrEmpty(index(local!tmodGivenNames.preferred_given_name,wherecontains(upper(fv!item),touniformstring(local!tmodGivenNames.enterprise_login_id)),{})),
                local!tmodGivenNames.given_name,
                local!tmodGivenNames.preferred_given_name
              ),
              {}
            ),
            if(
              a!isNullOrEmpty(local!blankTmodGivenName),
              fv!item,
              local!blankTmodGivenName
            )
          )
        },
        {
          xid: fv!item,
          name: user(fv!item, "firstName") & " " & user(fv!item, "lastName")
        }
      )
    )
  ),  
  a!recordFilterList(
    name: "Escalated To",
    isVisible: a!isNotNullOrEmpty(local!groupMembers),
    options: a!forEach(
      items: local!groupMembers,
      expression:a!recordFilterListOption(
        id: fv!index,
        name: fv!item.name,
        filter: a!queryFilter(
          field:'recordType!{92bc5c32-2509-4558-b252-56df608deb1a}.fields.{escalatedTo}',
          operator: "=",
          value: fv!item.xid
        )
      )
    )
  )
)

mikes0011
Brainy
April 18, 2024

It's not even necessary to do this in 2 steps.  Just replace the "null()" on line 47 with an empty set.

shubhama926776
April 18, 2024

 [mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] We can get rid of reject.

a!localVariables(
  local!group: index(
    rule!CDM2_findUserGroup(loggedInUser()),
    1,
    {}
  ),
  local!escalatedTo: if(
    a!isNullOrEmpty(local!group),
    {},
    index(
      a!queryEntity(
        entity: cons!CDM2_DSE_INQUIRIES,
        query: a!query(
          aggregation: a!queryAggregation(
            aggregationColumns: {
              a!queryAggregationColumn(field: "escalatedTo", isGrouping: true)
            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "groupId",
                operator: "=",
                value: local!group
              )
            },
            ignoreFiltersWithEmptyValues: false
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      "escalatedTo",
      null()
    )
  ),
  local!tmodData:a!flatten( a!forEach( 
    items: local!escalatedTo,
    expression: if(  
      a!isNullOrEmpty(fv!item),
      {}, 
      if(
        not(isusernametaken(fv!item)),
        fv!item,
        {}
      )
    )
  )
  ),
  local!tmodGivenNames: if(
    a!isNotNullOrEmpty(local!tmodData),
    index(
      a!queryEntity(
        entity: cons!TMODS_DSE,
        query: a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(field: "given_name"),
              a!queryColumn(field: "preferred_given_name"),
              a!queryColumn(field: "enterprise_login_id"),

            }
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "enterprise_login_id",
                operator: "IN",
                value: upper(local!tmodData)
              )
            },
            ignoreFiltersWithEmptyValues: true
          ),
          pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1)
        ),
        fetchTotalCount: false
      ),
      "data",
      null()
    ),
    {}
  ),  
  local!groupMembers:a!forEach(
    items:  local!escalatedTo,
    expression: if(
      a!isNullOrEmpty(fv!item),
      {},
      if(
        not(isusernametaken(fv!item)),
        {
          xid: fv!item,
          name: a!localVariables(
            local!blankTmodGivenName: displayvalue(
              upper(fv!item),
              touniformstring(
                local!tmodGivenNames.enterprise_login_id
              ),
              if(                
                /*a!isNullOrEmpty(local!tmodGivenNames.preferred_given_name),*/
                a!isNullOrEmpty(index(local!tmodGivenNames.preferred_given_name,wherecontains(upper(fv!item),touniformstring(local!tmodGivenNames.enterprise_login_id)),{})),
                local!tmodGivenNames.given_name,
                local!tmodGivenNames.preferred_given_name
              ),
              {}
            ),
            if(
              a!isNullOrEmpty(local!blankTmodGivenName),
              fv!item,
              local!blankTmodGivenName
            )
          )
        },
        {
          xid: fv!item,
          name: user(fv!item, "firstName") & " " & user(fv!item, "lastName")
        }
      )
    )
  ),  
  a!recordFilterList(
    name: "Escalated To",
    isVisible: a!isNotNullOrEmpty(local!groupMembers),
    options: a!forEach(
      items: local!groupMembers,
      expression:a!recordFilterListOption(
        id: fv!index,
        name: fv!item.name,
        filter: a!queryFilter(
          field:'recordType!{92bc5c32-2509-4558-b252-56df608deb1a}.fields.{escalatedTo}',
          operator: "=",
          value: fv!item.xid
        )
      )
    )
  )
)