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 ) ) } )
Discussion posts and replies are publicly visible
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", {}) )
Calling an integration in a foreach does not improve the code performance in any way. You will have to find a way to fetch the data for all documents in a single call.
I agree with you. I validated the approach and it showed slight improvement, but nothing major