filter() context

I'm trying to implement an expression rule that iterates over a list and returns a filtered list, and struggling to figure out how to do this.  It seems like filter() would be the way to go, but I don't see any examples of what the context parameter is supposed to look like.  What I want to do is something like:

rule input: fromDate (a Date)

rule:

filter(

rule!shouldItemBeIncluded(),

rule!getItemList(),

context: /* I'm lost here - I need to pass two parameters to shouldItemBeIncluded(), the item, and the fromDate */

)

How do I pass those parameters to the supplied predicate?

  Discussion posts and replies are publicly visible

Parents Reply
  • Here's the rule:

    filter(
    rule!OTM_ShouldTaskBeCreated(_, fromDate),
    rule!OTM_GetTaskDefinitions()
    )

    here's the error:

    Expression evaluation error in rule 'otm_shouldtaskbecreated': The load() function cannot be used within rules called by looping functions other than a!forEach(). Pass the necessary variables via rule inputs or use a!forEach().

    (because those rules do have load() to define temporary variables)

    also had tried:

    filter(
    rule!OTM_ShouldTaskBeCreated(),
    rule!OTM_GetTaskDefinitions(),
    fromDate
    )

    (rule OTM_ShouldTaskBeCreated() takes two parameters: the CDT that OTM_GetTasDefinitions() returns a list of, and a date)

    error:

    Expression evaluation error at function rule!OTM_ShouldTaskBeCreated [line 2]: Rule 'otm_shouldtaskbecreated' has 2 parameters, but instead passed 0 parameters.

Children