Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Currently , I am calling integration for each row separately,But I want optimize the code, Is there any way I can call integration just once and populate different row as per doc Id

Certified Senior Developer

a!localVariables(
  local!transactionCDM: index(
    index(
      rule!NW_Transaction(ri!transactionId),
      "result",
      {}
    ),
    "body",
    {}
  ),
  local!documentDetails: index(
    local!transactionCDM,
    "supporting_documents",
    {}
  ),
  local!selectedDocument,
  {
    if(
      a!isNotNullOrEmpty(local!selectedDocument),
      {
        /*{rule!NW_verticalSpacer(n: 4),*/
        rule!NW_UpdateDocumentDetails(
          selectedDocument: local!selectedDocument,
          transactionCDM: local!transactionCDM,
          showWhen: a!isNotNullOrEmpty(local!selectedDocument),
          transactionId: ri!transactionId
        )
      },
      a!cardLayout(
        contents: {
          a!recordActionField(
            actions: a!recordActionItem(
              action: 'recordType!{fff94020-d948-4267-8934-8f9a465308bd}NW Transaction.actions.{ba411847-1b0f-4a59-a70f-72a877d724f0}uploadDocument',
              identifier: ri!transactionId
            ),
            align: "END"
          ),
          a!gridField(
            data: local!documentDetails,
            columns: {
              a!gridColumn(
                label: "Document Form Name",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(fv!row, "form_name", {}),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    ),
                    link: a!safeLink(
                      uri: index(
                        index(
                          index(
                            rule!NW_GetDocumentDetails(docId: index(fv!row, "document_id", {})),
                            "result",
                            ""
                          ),
                          "body",
                          ""
                        ),
                        "document_url",
                        {}
                      ),
                      openLinkIn: "NEW_TAB"
                    ),
                    linkStyle: "STANDALONE"
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "Origination",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(
                        index(
                          index(
                            rule!NW_GetDocumentDetails(docId: index(fv!row, "document_id", {})),
                            "result",
                            ""
                          ),
                          "body",
                          ""
                        ),
                        "origination",
                        {}
                      ),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "Created On",
                sortField: "created_date",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(fv!row, "document_date", {}),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "External Contract Number",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(fv!row, "external_contract_number", {}),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "Status",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(fv!row, "document_state", {}),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "Updated On",
                sortField: "modified_date",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: todate(
                        index(
                          index(
                            index(
                              rule!NW_GetDocumentDetails(docId: index(fv!row, "document_id", {})),
                              "result",
                              ""
                            ),
                            "body",
                            ""
                          ),
                          "modified_date",
                          {}
                        )
                      ),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                ),
                align: "START"
              ),
              a!gridColumn(
                label: "Tracking Number",
                value: a!richTextDisplayField(
                  value: a!richTextItem(
                    text: a!defaultValue(
                      value: index(
                        index(
                          index(
                            rule!NW_GetDocumentDetails(docId: index(fv!row, "document_id", {})),
                            "result",
                            ""
                          ),
                          "body",
                          ""
                        ),
                        "tracking_number",
                        {}
                      ),
                      default: cons!NW_NULL_PLACEHOLDER_VALUE
                    )
                  )
                )
              ),
              a!gridColumn(
                value: a!richTextDisplayField(
                  value: {
                    a!richTextIcon(
                      icon: "dot-circle-o",
                      caption: "Update Document",
                      link: a!dynamicLink(
                        value: fv!row,
                        saveInto: local!selectedDocument
                      ),
                      linkStyle: "STANDALONE",
                      color: "POSITIVE"
                    )
                  },
                  showWhen: a!isNotNullOrEmpty(local!documentDetails)
                )
              )
            },
            pageSize: a!defaultValue(
              ri!pageSize,
              cons!CMGT_INT_BATCH_SIZE_SMALL
            )
          )
        },
        style: "NONE",
        shape: "ROUNDED",
        padding: "STANDARD",
        showBorder: false,
        showShadow: true,
        decorativeBarPosition: "TOP",
        decorativeBarColor: cons!NW_COLOR_PRIMARY
      )
    )
  }
)

Here , this integration  "rule!NW_GetDocumentDetails(docId: index(fv!row, "document_id", {}))", is called separately for different row , but I want to optimize it, please help regarding this scenario

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Old Answer: Fetch all document details once using a!forEach and store in local!allDocumentDetails.
    Access data using local!allDocumentDetails[fv!index] instead of calling the integration.

    New Answer: Only way to truly improve performance is to modify the integration to accept array of Ids.

    /* Instead of N calls, make ONE call */
    local!allDocumentDetails: rule!NW_GetDocumentDetailsBatch(
      docIds: index(local!documentDetails, "document_id", {})
    )

Reply
  • 0
    Certified Lead Developer

    Old Answer: Fetch all document details once using a!forEach and store in local!allDocumentDetails.
    Access data using local!allDocumentDetails[fv!index] instead of calling the integration.

    New Answer: Only way to truly improve performance is to modify the integration to accept array of Ids.

    /* Instead of N calls, make ONE call */
    local!allDocumentDetails: rule!NW_GetDocumentDetailsBatch(
      docIds: index(local!documentDetails, "document_id", {})
    )

Children