load( preSortPage:todatasubset({}), chargeSearch: "", pagingInfo: a!pagingInfo(startIndex: 1, batchSize: cons!NOD_BATCH_SIZE, sort:rule!NOD_lineItemSort(true)), gSelection: a!gridSelection(pagingInfo: local!pagingInfo), showSearch: false,chargeSearchField,locationField,tradeIntervalField,TradeHourField,location, tradeHour, tradeMinute, addButton, addedItems: ri!addedLineItems, selectedCRSItems, addInfo: a!pagingInfo(startIndex: 1, batchSize: cons!NOD_BATCH_SIZE, sort: rule!NOD_lineItemSort(true)), addSel: a!gridSelection(selected: {}, pagingInfo: local!addInfo), showInstructions: false, a!formLayout( label: cons!NOD_SELECT_PSS_LINE_ITEMS, firstColumnContents: { rule!NOD_displayFormMilestones(2,"0"), rule!NOD_uiComponentPSSDetails(ri!noticeOfDisagreement.crsStatementId_int,ri!noticeOfDisagreement.crsStatementIssued_datetime, index(ri!noticeOfDisagreement,"cdmsOrganizationName_text",""),ri!noticeOfDisagreement.crsMarketType_text,ri!noticeOfDisagreement.crsOrgId_int, ri!noticeOfDisagreement.crsStatementPrimaryTrade_datetime), a!textField(readOnly: true), a!sectionLayout( label:cons!NOD_PSS_LINE_ITEMS ), a!textField( labelPosition: "COLLAPSED", value: cons!NOD_SUBMISSION_SEARCH_INSTRUCTIONS_SMALL, readOnly: true ), if(local!showInstructions, a!paragraphField( labelPosition: "COLLAPSED", value: cons!NOD_SUBMISSION_SEARCH_INSTRUCTIONS_FULL, readOnly: true ), {}), a!linkField( labelPosition: "COLLAPSED", links: a!dynamicLink( label: if(local!showInstructions, cons!NOD_LABEL_HIDE_DETAILED_INSTRUCTIONS, cons!NOD_LABEL_SHOW_DETAILED_INSTRUCTIONS), value: not(local!showInstructions), saveInto: local!showInstructions ) ), a!pickerFieldCustom( label: cons!NOD_CHARGE_TYPE, labelPosition: cons!NOD_LABEL_POSITION, maxSelections: 1, suggestFunction: rule!NOD_uiPickerChargeTypes(filter: _, labels: ri!chargeTypes.crsChargeTypeName_text, identifiers: ri!chargeTypes.crsChargeTypeId_int), selectedLabels: if( or(isnull(local!chargeSearchField), count(local!chargeSearchField)=0), null, apply(rule!NOD_uiPickerChargeSelectionLabels(identifier: _, labels: ri!chargeTypes.crsChargeTypeName_text, identifiers: ri!chargeTypes.crsChargeTypeId_int), local!chargeSearchField) ), value: local!chargeSearchField, required: true, requiredMessage: cons!NOD_ENTER_CHARGE_TYPE, validations: if(rule!NOD_util_isNullOrEmpty(local!chargeSearchField), cons!NOD_ENTER_CHARGE_TYPE, ""), saveInto: local!chargeSearchField ), a!textField( label: "* "&cons!NOD_LOCATION_ID, labelPosition: cons!NOD_LABEL_POSITION, instructions: "The Location ID field is mandatory for line items with location IDs. Leaving this field blank will return line items with no associated Location IDs", /** required: true, requiredMessage: "Please enter a location id to search.", **/ value: local!locationField, saveInto: local!locationField ), a!sectionLayout( label: "", firstColumnContents: { a!dropdownField( label: cons!NOD_TRADING_HOUR, labelPosition: cons!NOD_LABEL_POSITION, placeholderLabel: cons!NOD_SELECT_TRADE_HOUR, choiceLabels: {cons!NOD_TRADE_HOUR_DROPDOWN_LABELS}, choiceValues: {cons!NOD_TRADE_HOUR_VALUES}, value: local!tradeHourField, saveInto: local!tradeHourField ) }, secondColumnContents: { a!dropdownField( label: cons!NOD_TRADING_MINUTE, labelPosition: cons!NOD_LABEL_POSITION, placeholderLabel: cons!NOD_SELECT_TRADE_MINUTE, choiceLabels: {cons!NOD_TRADE_INTERVAL_VALUES}, choiceValues: {cons!NOD_APPENDED_TRADE_INTERVAL_VALUES}, value: local!tradeIntervalField, saveInto: local!tradeIntervalField ) } ), a!buttonLayout( secondaryButtons: { a!buttonWidget( label: cons!NOD_BUTTON_SEARCH, value: true, validate: true, saveInto: { local!showSearch << rule!NOD_formRule_returnTrue, a!save( local!preSortPage, rule!NOD_getCrsLineItemsForEnterDetailsForm( local!chargeSearchField, local!locationField, local!tradeHourField, local!tradeIntervalField, a!pagingInfo(startIndex:1,batchSize:-1), ri!noticeOfDisagreement.crsStatementId_int ) ) } ) } ), if(local!showSearch, { with( page:todatasubset(preSortPage.data, local!gSelection.pagingInfo), if( rule!NOD_util_isNullOrEmpty(local!page.data), a!textField( readOnly: true, value: cons!NOD_NO_LINE_ITEM, label: cons!NOD_SEARCH_RESULTS ), { a!gridField( label: cons!NOD_SEARCH_RESULTS, instructions: cons!NOD_SELECT_LINES, selection: true, totalCount: local!page.totalCount, columns: { a!gridTextColumn( label: cons!NOD_RECORD, field: "recordType_text", data: local!page.data.recordType_text, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_CHARGE_TYPE, field: "chargeTypeId_int", data: local!page.data.chargeTypeId_int, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_DATE, field: "tradingDate_datetime", data: local!page.data.tradingDate_datetime, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_HOUR, field: "tradeHour_int", data: local!page.data.tradeHour_int, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_MINUTE, field: "tradeMinute_int", data: local!page.data.tradeMinute_int, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_SETTLEMENT_AMOUNT, field: "settlementAmount_dec", data: apply(rule!NOD_util_formatDollar,local!page.data.settlementAmount_dec), alignment: "RIGHT" ), a!gridTextColumn( label: cons!NOD_LOCATION_ID, field: "locationId_int", data: local!page.data.locationId_int, alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_ADJUSTMENT_COMMENT, field: "adjustmentComment_text", data: local!page.data.adjustmentComment_text, alignment: "LEFT" ) }, identifiers: local!page.data.crsLineItemId_int, value: local!gSelection, saveInto: { a!save(local!gSelection,save!value), a!save( local!selectedCRSItems, rule!NOD_lookupIntegersAndReturnAnyType( save!value.selected, local!page.data.crsLineItemId_int, local!page.data ) ), a!save( local!gSelection.pagingInfo.sort, append( local!gSelection.pagingInfo.sort, a!sortInfo( field: "tradeMinute_int", ascending: true ) ) ), } ), a!buttonLayout( secondaryButtons:{ a!buttonWidget( label: cons!NOD_BUTTON_ADD, value: local!selectedCRSItems, skipValidation: true, style: "PRIMARY", disabled: if(rule!APN_isEmpty(local!gSelection.selected),true,false), saveInto: { local!addedItems << union(local!addedItems,_) << append(local!addedItems, _), ri!addedLineItems << union(local!addedItems,_) << append(local!addedItems, _), a!save(local!selectedCRSItems, null), a!save(local!gSelection.selected, {}), a!save(local!addSel.selected, {}) } ) } ) } ) ) }, {} ), a!textField(readOnly:true), a!sectionLayout( label: cons!NOD_ADDED_ITEMS, firstColumnContents: { with(addPage: todatasubset(local!addedItems, local!addSel.pagingInfo), a!gridField( selection: true, totalCount: local!addPage.totalCount, columns: { a!gridTextColumn( label: cons!NOD_RECORD, field: "recordType_text", data: index(local!addPage.data, "recordType_text", null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_CHARGE_TYPE, field: "chargeTypeId_int", data: index(local!addPage.data,"chargeTypeId_int", null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_DATE, field: "tradingDate_datetime", data: index(local!addPage.data, "tradingDate_datetime",null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_HOUR, field: "tradeHour_int", data: index(local!addPage.data, "tradeHour_int", null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_TRADING_MINUTE, field: "tradeMinute_int", data: index(local!addPage.data, "tradeMinute_int", null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_SETTLEMENT_AMOUNT, field: "settlementAmount_dec", data: if(isnull(local!addPage.data),null,apply(rule!NOD_util_formatDollar, index(local!addPage.data, "settlementAmount_dec", {}))), alignment: "RIGHT" ), a!gridTextColumn( label: cons!NOD_LOCATION_ID, field: "locationId_int", data: index(local!addPage.data,"locationId_int",null), alignment: "LEFT" ), a!gridTextColumn( label: cons!NOD_ADJUSTMENT_COMMENT, field: "adjustmentComment_text", data: index(local!addPage.data,"adjustmentComment_text",null), alignment: "LEFT" ) }, identifiers: index(local!addPage.data, "crsLineItemId_int",null), value: local!addSel, saveInto: {local!addSel, a!save(local!addSel.pagingInfo.sort, append(local!addSel.pagingInfo.sort,a!sortInfo( field: "tradeMinute_int", ascending: true() )))} ) ), if(rule!NOD_util_isNullOrEmpty(local!addedItems), {}, a!buttonLayout( secondaryButtons: { a!buttonWidget( label: cons!NOD_BUTTON_REMOVE, style: if(count(local!addSel.selected)>0, "DESTRUCTIVE", ""), disabled: if(count(local!addSel.selected)>0, false, true), confirmMessage: cons!NOD_REMOVE_SELECTED_LINE, skipValidation: true, value: local!addSel, saveInto: { a!save(ri!deletedLineItemIds, append(ri!deletedLineItemIds, index(save!value,"selected"))), local!addedItems << rule!NOD_lookupAndRemove(_, local!addedItems.crsLineItemId_int, local!addedItems) << index(_, "selected"), ri!addedLineItems << rule!NOD_lookupAndRemove(_, local!addedItems.crsLineItemId_int, local!addedItems) << index(_, "selected"), a!save(local!addSel.pagingInfo, rule!NOD_getPagingInfoByCRUD(0, local!addSel.pagingInfo, length(local!addedItems)-1, index(local!addSel.selected,length(local!addSel.selected),1))), a!save(local!addSel.selected,null) } ) } ) ), if(length(union(local!addedItems.chargeTypeId_int,local!addedItems.chargeTypeId_int))>1, a!textField( label:"", readOnly: true, value:cons!NOD_DIFFERENT_CHARGE_TYPE ),{}) } ), }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: cons!NOD_BUTTON_SAVE_CONTINUE, value: cons!NOD_BUTTON_SAVE_CONTINUE, style: "PRIMARY", skipValidation: true, confirmMessage: if(rule!APN_isEmpty(local!addedItems), "", if(length(union(local!addedItems.chargeTypeId_int,local!addedItems.chargeTypeId_int))>1, cons!NOD_DIFFERENT_CHARGE_TYPES, "" ) ), saveInto: { ri!button, ri!addedLineItems << rule!NOD_formRule_returnFirstInput(local!addedItems, _) } ), a!buttonWidgetSubmit( label: cons!NOD_BUTTON_CANCEL, value: cons!NOD_BUTTON_CANCEL, skipValidation: true, saveInto: ri!button ) }, secondaryButtons: { a!buttonWidgetSubmit( label: cons!NOD_BUTTON_PREVIOUS, value: cons!NOD_BUTTON_PREVIOUS, skipValidation: true, saveInto: ri!button ) } ) ) )