or function doesn't seem to be working as expected

I have this expression rule :

a!localVariables(
  /* Loop checks against passed in value of type to pull values
     from specific requirementActivity match */
  a!forEach(
    items: ri!requirement.requirementActivities, 
    expression: 
    if(contains(fv!item.type, ri!activityType),
      'type!{urn:com:appian:types:UW}UW-Requirement-Activity'(
        key: fv!item.key,
        type: fv!item.type,
        creatorId: fv!item.creatorId,
        creatorFullName: fv!item.creatorFullName,
        createdDate: fv!item.createdDate,
        commentText: fv!item.commentText
    ), 
    {}), 
  ),
),

And I'm using it in my interface :

a!localVariables(
      requirementsResponse: rule!UW_GetRequirementsByCase_RDS("SomeKey"),
      local!requirements: {
        a!forEach(
          items: local!requirementsResponse,
          expression: 
          a!map(
            type: fv!item.name,
            status:fv!item.status,
            orderDate: fv!item.createdTimestamp,
            orderRep: fv!item.requestedBy,
            receiveDate: rule!UW_GetRequirementActivityByType(fv!item, "RECEIVED").createdDate,
            receiveRep: rule!UW_GetRequirementActivityByType(fv!item, "RECEIVED").creatorFullName,
            resolveDate: rule!UW_GetRequirementActivityByType(fv!item, or("WITHDRAWN", "ACCEPTED")).createdDate,
            resolveRep: rule!UW_GetRequirementActivityByType(fv!item, or("WITHDRAWN", "ACCEPTED")).creatorFullName,
            resolutionStatus: rule!UW_GetRequirementActivityByType(fv!item, or("ACCEPTED", "WITHDRAWN")).type,
            resolutionNotes: rule!UW_GetRequirementActivityByType(fv!item, or("ACCEPTED", "WITHDRAWN")).commentText
            )
        )
      },

Which I'm using to help populate fields. Everything works great until I save close out and go back...

Then I end up with this error: "Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 6]: Error in a!forEach() expression during iteration 11: Expression evaluation error at function a!map parameter 7 [line 16]: Invalid index: Cannot index property 'createdDate' of type Text into type List of Variant"

Which is pointing to : resolveDate: rule!UW_GetRequirementActivityByType(fv!item, or("WITHDRAWN", "ACCEPTED")).createdDate,

It's not a fan of how I am using the or function - if I remove it and just pass one of the options all is fine. However I only want these fields populated if one or the other value is found. Is there another way to do this? I feel like this should work and again it does but then it does not.

  Discussion posts and replies are publicly visible

Parents
  • First to note, the or() function is expecting boolean inputs, you are sending it text inputs so it will always return false.  Are these status values found in fv!item.status?  Assuming so, a proper or() function usage would be:

    or(fv!item.status="WITHDRAWN",fv!item.status="ACCEPTED")

    However, judging by the other calls to rule!UW_GetRequirementActivityByType, the second input is expecting a text status value.  This parameter would need to be configured to accept multiple values and the or() logic would be implemented inside that rule.  At which time, you would send these values from the parent interface such as {"WITHDRAWN","ACCEPTED}, in place of your or() calls.  Currently, inputs to this parameter are a mix of text and boolean.

  • Thank you Chris - I did follow your suggestion around making the activityTypes an array in my expression input rules. I went through appian training months ago but didn't get a task until this week. My entire team is new to appian. So I appreciate your explanation and patience.

Reply Children