/*data inputs are: newTeamLink_cdt, newTeam_cdt, existingProduct_cdt, selectedSubmission_cdt, whereTo_txt*/ = load( local!newLinkToken, a!formLayout( label: "Team (" & ri!newTeam_cdt.teamname & ")", firstColumnContents: { a!sectionLayout( firstColumnContents: { a!textField( label: "Submission Type", labelPosition: "ABOVE", value: ri!selectedSubmission_cdt.submissionType, saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!textField( label: "Category", labelPosition: "ABOVE", value: ri!selectedSubmission_cdt.category, saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!dateField( label: "Received Date", labelPosition: "ABOVE", value: ri!selectedSubmission_cdt.receivedDate, saveInto: {}, required: false, readOnly: true, validations: {} ), a!dateField( label: "Board Suspense Date", labelPosition: "ABOVE", value: if(ri!selectedSubmission_cdt.boardSuspenseDate = "", "TBD", ri!selectedSubmission_cdt.boardSuspenseDate), saveInto: {}, required: false, readOnly: true, validations: {} ) }, secondColumnContents: { a!textField( label: "Commodity", labelPosition: "ABOVE", value: if(ri!existingProduct_cdt.commodityId="", "N/A", rule!ips_getCommodityNameById(ri!existingProduct_cdt.commodityId).commodityName), saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ), a!textField( label: "Insurance Plan", labelPosition: "ABOVE", value: if(ri!existingProduct_cdt.planTypeId="", "N/A", rule!ips_getPlanTypeNameById(ri!existingProduct_cdt.planTypeId).plantypename), saveInto: {}, refreshAfter: "UNFOCUS", readOnly: true, validations: {} ) } ), a!sectionLayout( label: "Team Composition", /*Editable Grid for assigning roles to selected users*/ firstColumnContents: { a!gridLayout( headerCells:{ a!gridLayoutHeaderCell( label: "Name" ), a!gridLayoutHeaderCell( label: "Roles" ) }, columnConfigs: { a!gridLayoutColumnConfig( width: "DISTRIBUTE" ), a!gridLayoutColumnConfig( width: "DISTRIBUTE" ) }, rows: a!applyComponents( function: rule!ips_assignUserRolesGrid( newTeamLink_cdt: ri!newTeamLink_cdt, index: _, newLinkToken: local!newLinkToken ), array: if(or(isnull(ri!newTeamLink_cdt), count(ri!newTeamLink_cdt) < 1), {}, 1+enumerate(count(ri!newTeamLink_cdt))), arrayVariable: local!newLinkToken ), validations: if( or( isnull( ri!newTeamLink_cdt ), count( ri!newTeamLink_cdt ) < 1 ), "You must assign roles to all selected team members.", {} ) ), a!linkField( label: "Add Link", labelPosition: "COLLAPSED", links: a!dynamicLink( label: "+ Add Team Member", value: 'type!{urn:com:appian:types}IPS_TeamLink'(), saveInto: { a!save( ri!newTeamLink_cdt, append( ri!newTeamLink_cdt, save!value ) ), a!save( local!newLinkToken, append( local!newLinkToken, save!value ) ) } ) ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidgetSubmit( label: "Submit", style: "PRIMARY", saveInto: ri!whereTo_txt, skipValidation: true ) }, secondaryButtons: { a!buttonWidgetSubmit( label: "Cancel", style: "NORMAL", value: true, saveInto: ri!whereTo_txt, skipValidation: true ) } ) ) )