Skip to main content
December 27, 2024
Solved

Expression Rule for iterating through Documents

  • December 27, 2024
  • 6 replies
  • 0 views

Appian Community Team,

I need to have an Expression Rule that does the below:

Takes 2 Rule Inputs:

1. reviewID (Number data type)

2. file (Document Data type, this is Array holding list of documents)

I need to write an Expression rule that iterates through the Rule Input file and then outputs a list of Record Data ReviewDocument, this ReviewDocument record will have data points from both Rule Input reviewID and File.

Can you please advise on sample code for this.

Best answer by venkatrea696188

Can you be more specific about the output? You want something like this??

 

a!foreach(ri!file,
recordtype!XYZ(
documet: fv!item,
reviewid:ri!review id))

6 replies

stefanhelzle0001
December 27, 2024

What exactly do you want to do with these documents? Can you describe how the output of that expression should look like?

December 27, 2024

Hi [mention:a11f77a729fb4db2af76b09948583328:e9ed411860ed4f2ba0265705b8793d05] ,

I have a Table(Record) called REVIEW_DOCUMENTS in the Database. This Table has below data points:

REVIEW_ID

DOCUMENT_ID

DOCUMENT_NAME

I want to populate above Record with Review ID and Documents information using an Expression Rule, we can expect to have multiple Documents for a given Review ID. Then eventually in the process model I want to write that Records output into a Database Table REVIEW_DOCUMENTS so that I can show the documents to users in Summary screens.

To your question on what I was expecting the Expression Rule to output, I want that to display list of ReviewDocuments Records with Review Id, Doc Id and Doc Name data points in each.

Please let me know if you are having any questions. I am open for suggestions if I am not thinking correctly here.

Regards,

Mahesh

stefanhelzle0001
December 27, 2024

This looks like a good case for a foreach() iterating on the documents. The expression part of the foreach() creates a new record for each of the documents using the reviewId value from the rule input.

https://docs.appian.com/suite/help/24.4/reference-records.html#use-a-record-type-constructor

venkatrea696188
December 27, 2024

Can you be more specific about the output? You want something like this??

 

a!foreach(ri!file,
recordtype!XYZ(
documet: fv!item,
reviewid:ri!review id))

December 27, 2024

Thank you [mention:ba9672c2f5294cb98c0a2b8fb79cf967:e9ed411860ed4f2ba0265705b8793d05] , This is helpful. Appreciate the quick response here.